コンテンツにスキップ

Unity

AD(X)のためのAdkit: Unity

AdKitは、AD(X) Unityパッケージの処理中に発生したエラーを修正し、ユーザーの利便性をサポートする広告モジュールです。このページを一つずつ読んで、AdKitおよびサポートSDKの使用方法を確認してください。

インストール

Hive 開発者にアクセスし、AdKitをダウンロードして適用してください。

  1. Hive 開発者から AdKit の最新バージョンをダウンロードし、ここで解凍します here.
  2. Unity ツールバーで、Assets > Import Package > Custom Package… の下にある .unitypackage ファイルを選択し、Import をクリックします。

  1. インポート完了後、Assetsフォルダー内にAdKitおよびAD(X)関連のファイルとフォルダーが作成されているか確認してください。

Warning

開発中にAdKitをテストする際は、テスト広告キーを適用する必要があります。

更新

アンインストールしているAdKitを削除し、最新バージョンをインストールして更新してください。

使い方

iOS (Unity 2019.4 以降)

Unity 2019.4以降でiOSプロジェクトをビルドすると、Dynamic Frameworkとして動作するUnityFrameworkターゲットが作成されます。

  1. EDM4Uを設定します。 UnityのiOS Resolver Settings(Assets > External Dependency Manager > iOS Resolver > Settings)で、static_frameworkビルド設定(Link frameworks statically)を確認します。 (1.2.171) Facebook SDKはDynamic Frameworkのみを提供しますが、Podfileでは2つの方式のうち一方のみを設定できます。そのため、Link frameworks staticallyを有効にしてFacebook SDKを使用する場合は、以下の該当するコメントを解除します。

    string[] frameworksToEmbed = {
        ...
        "FBAudienceNetwork.xcframework",
    
        // Facebook SDKを使用する場合は、使用するSDKのコメントを解除してください。
        // "FBAEMKit.xcframework",
        // ...
    };
    

    Warning
    • 現在使用しているFacebook SDKのみコメントを解除してください。
    • Link frameworks staticallyが無効な状態、つまりDynamic Framework使用時にコメントを解除すると競合する場合があります。
  2. プロジェクトをビルドします。

    Warning

    Xcodeプロジェクトの生成中にpod installが失敗し、上記でLink frameworks staticallyを有効にしていた場合は、生成されたプロジェクトで直接pod installを実行せず、Unity Editorからプロジェクトを再ビルドしてください。

機能

  • リワード広告
    • AdKit APIとSDKを併用する場合、または個別モジュールを使用する場合、ログ情報を送信するかどうかは呼び出したRewardVideo APIによって決まります。ログ情報はAnalyticsサーバーに送信されます。この機能をサポートする最小バージョンは以下のとおりです。
      • SDK v4.11.0
      • SDK v1.17.2
      • 個別モジュール ModuleManager v2.6.0
      • 個別モジュール CommonModule v1.5.0
  • インタースティシャル広告
  • アダプティブバナー広告

AdKitの使用方法の詳細については、以下のガイドをお読みください。

AdKitの初期化

初期化、読み込み、すべての種類の広告(AD)を表示する前に必要なステップ

ヨーロッパおよび英国ターゲティング

あなたのゲームがヨーロッパとイギリス(EEAおよびUK)を対象とする場合、GDPR(一般データ保護規則)同意ポップアップを表示する必要があります。Adkitは、GDPR同意ポップアップを表示するためにGoogleのUMP(ユーザーメッセージングプラットフォーム)をサポートしています。Google UMPを使用するには、まずGDPRメッセージ作成ガイドを参照して、GDPRメッセージを作成してください。

Hive SDKを使用する際、AuthV4.setupはIDFAメッセージを公開するため、IDFAメッセージの作成は基本的にオプションです。ただし、GDPRメッセージを使用している場合は、IDFAメッセージとATT通知に関する詳細な説明に従ってIDFAメッセージを作成する必要があります。

GDPRメッセージとIDFAメッセージの両方を作成した場合は、以下に示すようにInitializeWithShowADXConsentでHive AdKitを初期化してください。

Important

Hive SDKを使用している場合は、Hive AdKitの初期化が完了した後にAuthV4.setupを実行する必要があります。ATT(アプリトラッキング透明性)同意通知を表示した後にGDPR同意画面が表示されると、Appleのアプリレビュー中にアプリが拒否される可能性があります。

// When targeting Europe & the UK for commercial distribution
int debugState = 0;
HIVEAdKit.InitializeWithShowADXConsent(appId, debugState, null, adkitConsentState =>
{
    /*
    * adkitConsentState : User's personal information usage and collection status for AD(X)
    * - 0 : No consent status exists
    * - 1 : Region where consent is not required
    * - 2 : User has refused the usage and collection of personal information
    * - 3 : User has consented to the usage and collection of personal information
    */
});

/* 
 * To test the GDPR consent popup, set debugState to 1 and configure testDeviceId to display the GDPR test popup.
 * The device ID for the Test Device (testDeviceId) can be found in the Android Logcat and Xcode console logs.
 * The testDeviceId is used only for testing. You must specify testDeviceId as null during commercial distribution.
 * Example Android log: Use new ConsentDebugSettings.Builder().addTestDeviceHashedId("ABCDEFGHIJKLMNOPQRSTUVWXYZ") to set this as a debug device.
 * Example Xcode log: To enable debug mode for this device, set: UMPDebugSettings.testDeviceIdentifiers = @[ABCDEFGHIJKLMNOPQRSTUVWXYZ]
 */

int debugState = 1;
string testDeviceId = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
List testDevices = new List();
testDevices.Add(testDeviceId);

HIVEAdKit.InitializeWithShowADXConsent(appId, debugState, testDevices, adkitConsentState =>
{
    /*
    * adkitConsentState : User's personal information usage and collection status for AD(X)
    * - 0 : No consent status exists
    * - 1 : Region where consent is not required
    * - 2 : User has refused the usage and collection of personal information
    * - 3 : User has consented to the usage and collection of personal information
    */
});

Hive AdKitを初期化する際、ターゲット地域がヨーロッパおよび英国(EEAおよびUK)と判断されると、GDPR同意画面が以下のように自動的に表示されます。

iOS環境では、IDFAの説明メッセージがヨーロッパおよび英国以外の地域で自動的に表示されます。

その他の地域をターゲットにする

ヨーロッパおよび英国以外の地域をターゲットにする場合は、InitializeWithSetConsentStateで初期化します。

/*
 * Set the user's personal information usage and collection status for AD(X)
 * 0 : No consent status exists
 * 1 : Region where consent is not required
 * 2 : User has refused the usage and collection of personal information
 * 3 : User has consented to the usage and collection of personal information
 */
int consentState = 1;
HIVEAdKit.InitializeWithSetConsentState(appId, consentState);

高度な設定

// GameData Example
[Serializable]
public class SendInfo 
{
    public int level;
    public int gold;
}
SendInfo addtionalInfo = new SendInfo();
addtionalInfo.level = 1;
addtionalInfo.gold = 100;

// Send as a JSON Obejct format
HIVEAdKit.SetAdditionalInfo(JsonUtility.ToJson(addtionalInfo));

報酬タイプ

// Initialize Rewarded AD
// Initialize Rewarded AD
EventHandlers eventHandlers = new EventHandlers.Builder()
                                                .OnAdLoaded(OnAdLoadedCB)
                                                .OnAdOpening(OnAdOpeningCB)
                                                .OnAdClosed(OnAdClosedCB)
                                                .OnAdFailedToLoad(OnAdFailedToLoadCB)
                                                .OnAdFailedToShow(OnAdFailedToShowCB)
                                                .OnAdReward(OnAdRewardCB)
                                                .OnPaidEvent(OnPaidEventCB)
                                                .Build();
// Generate an instance
RewardVideoAd = HIVEAdKit.RewardVideo.Initialize(rewardVideoUnitId, eventHandlers);

// Load Rewarded AD
// Send AD loading information to Analytics
if( HIVEAdKit.RewardVideo.IsInitialzed(RewardVideoAd) ) {
    HIVEAdKit.RewardVideo.LoadAd(RewardVideoAd, "Unity-AdaptiveBanner-Show-AdditionalInfo");
}

// Show RewardVideo type
// Send AD loading information to Analytics
if( HIVEAdKit.RewardVideo.IsLoaded(RewardVideoAd) ) {
    HIVEAdKit.RewardVideo.Show(RewardVideoAd, "Unity-AdaptiveBanner-Show-AdditionalInfo");
}

インタースティシャルタイプ

EventHandlers eventHandlers = new EventHandlers.Builder()
                                                .OnAdLoaded(OnAdLoadedCB)
                                                .OnAdOpening(OnAdOpeningCB)
                                                .OnAdClosed(OnAdClosedCB)
                                                .OnAdFailedToLoad(OnAdFailedToLoadCB)
                                                .OnAdClick(OnAdClickCB)
                                                .OnPaidEvent(OnPaidEventCB)
                                                .Build();
// Generate an instance
InterstitialAd = HIVEAdKit.Interstitial.Initialize(InterstitialAdUnitId, eventHandlers);

// Load
// Send AD loading information to Analytics
if( HIVEAdKit.Interstitial.IsInitialzed(InterstitialAd) ) {
     HIVEAdKit.Interstitial.Load(InterstitialAd, "Unity-AdaptiveBanner-Show-AdditionalInfo");
}

// Show
// Send AD loading information to Analytics
if( HIVEAdKit.Interstitial.IsLoaded(InterstitialAd) ) {
     HIVEAdKit.Interstitial.Show(InterstitialAd, "Unity-AdaptiveBanner-Show-AdditionalInfo");
}

アダプティブバナータイプ

EventHandlers eventHandlers = new EventHandlers.Builder()
                                                            .OnAdLoaded(OnBannerAdLoadedCB)
                                                            .OnAdOpening(OnAdOpeningCB)
                                                            .OnAdClosed(OnAdClosedCB)
                                                            .OnAdFailedToLoad(OnAdFailedToLoadCB)
                                                            .OnAdClick(OnAdClickCB)
                                                            .OnPaidEvent(OnPaidEventCB)
                                                            .Build();
HIVEAdKit.AdaptiveBanner.AdPosition bannerPosition = HIVEAdKit.AdaptiveBanner.AdPosition.Top;
HIVEAdKit.AdaptiveBanner.AdSize adaptiveSize = HIVEAdKit.AdaptiveBanner.AdSize.AD_SIZE_320x50;

// Generate an instance
AdaptiveBannerAd = HIVEAdKit.AdaptiveBanner.Initialize(AdaptiveBannerAdUnitId, adaptiveSize, bannerPosition, eventHandlers);

// Load and show
// Send AD loading information to Analytics
HIVEAdKit.AdaptiveBanner.LoadAd(AdaptiveBannerAd, "Unity-AdaptiveBanner-Show-AdditionalInfo");

// Hide
HIVEAdKit.AdaptiveBanner.Destroy(AdaptiveBannerAd);

iOS 14のサポート

以下は、iOS 14以降をサポートするAD(X)のSKAdNetworkリストです。AdKitPostprocessは2021年1月29日の更新に基づいています。最新の更新を確認することを忘れないでください。

Android 11のサポート

AD(X)ライブラリのAndroidManifest.xmlファイルに、Android 11をサポートするために<queries>タグが追加されます。プロジェクトをUnityでビルドしている際に以下のようなエラーログが表示された場合は、Unity-Android 11でビルドするためのガイドラインを参照してください。

  • Unityのサンプルエラーログ
  AndroidManifest.xml: AAPT: error: unexpected element <queries> found in <manifest>.

ADX Proguard 設定

ライブラリのAARファイルにはProguardのルールが含まれているため、設定が自動的に実行されます。  

Unity統合通知

GoogleMobileAdsSettingsのApp IDが削除された場合は、Unity > Assets > Google Mobile Ads > Settingsに移動し、Delay app measurementチェックボックスを選択してから、再度クリアしてください。

 

テスト広告

開発中にテスト広告がクリックされたときに広告主が料金を請求されないことは重要です。テストモードから広告をあまりにも多くクリックすると、それは無効なアクションと見なされます。したがって、報告対象アカウントにならないように注意してください。テスト広告を使用するには、Google Developersを参照してください。

 

エラーコード

広告の読み込みに失敗したときのコードとメッセージは、AD(X)のAd Errorで確認できます。

アンインストール

AD(X)用のAdKitをアンインストールするには、以下のファイルとフォルダーのリストを削除してください。

    • AdKitに関連
      • /Assets/HIVEAdKit
      • /Assets/HIVEAdKit_Example
    • AD(X)に関連
      • /Assets/ADXLibrary
      • /Assets/GoogleMobileAds
      • /Assets/Plugins/Android/GoogleMobileAdsPlugins
Note

AD(X)に関連するファイルのリストは、AdKitに含まれるAD(X)のバージョンによって異なる場合があります。