跳轉至

Unity

Hive AdKit for ADOP: Unity

Hive AdKit for ADOP(以下称为 AdKit for ADOP)使用 ADOP 的 API,并根据 ADOP 开发指南进行开发。使用 AdKit for ADOP 与 Hive SDK 或单独模块一起时,日志将被发送到分析服务器,从而省略单独的广告分析工作。 本指南是为 Hive SDK 用户编写的 AdKit for ADOP 应用指南,旨在帮助修复在应用 ADOP 提供的 Unity 包过程中出现的错误,并减少试错,以提高使用的便利性。了解支持 AdKit for ADOP 的版本和应用方法。

安裝

  1. 下載並安裝 AdKit for ADOP 的最新版本。
  2. 在 Unity 工具欄中選擇 Assets > Import Package > Custom Package...,然後選擇 .unitypackage 文件並點擊 Import。
  3. 導入完成後,請確認在 Assets 文件夾下生成了 Hive AdKit 及 ADOP 相關文件和文件夾。
  4. 請下載並安裝最新版本的EDM4U 下載。
    • Hive SDK v4包含EDM4U。如果您使用Hive SDK v4,則可以跳過此步驟。
Warning

在進行 AdKit 測試時,必須應用 測試 廣告金鑰。

更新

使用中的 AdKit 請刪除並安裝最新版本以進行更新。

設定

請根據以下的操作系統指南設置 AdKit。

  • Android
    在 Unity 项目中生成的 Assets/Plugins/Android/AndroidManifest.xml 文件中添加 ca-app-pub-XXXXX~YYYYY 格式的 `AdMobId` 值。
    <application>
        <!-- AdKit -->
        <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-XXXXX~YYYYY"/>
        <meta-data android:name="com.google.android.gms.ads.AD_MANAGER_APP" android:value="true" />
        <!-- AdKit -->
        </application>
    
  • iOS
    在 Unity 构建时生成的 Xcode 项目的 Info.plist 文件中添加 GADApplicationIdentifier,并将格式为 ca-app-pub-XXXXX~YYYYY 的 AdMobId 值输入为 String 类型。
    <key>GADApplicationIdentifier</key>
    <string>ca-app-pub-XXXXX~YYYYY</string>
    
    iOS 14 以上時,請將 ADOP 的 SKAdNetwork 列表 添加到 Info.plist 文件中。(使用 Assets/Bidmad/Editor/BidmadPostProcessBuild.cs 文件在構建時自動添加。)

應用

iOS PrivacyInfo

有關發布應用程式時填寫隱私權調查所需的資訊,請參閱 [Privacy Survey 指南]。(https://github.com/bidmad/Bidmad-iOS/wiki/Guide-for-Privacy-Manifest-&-Privacy-Survey-%5BKR%5D#앱-배포-및-개인정보-라벨-생성).

ADOP Proguard 設定

如果您正在使用 Proguard,则需要添加以下 ADOP Proguard 设置。

  -keep class com.adop.sdk.** { *; }
  -keep class ad.helper.openbidding.** { *; }
  -keep class com.adop.sdk.adapter.**{ *; }
  -keepnames class * implements java.io.Serializable
  -keepclassmembers class * implements java.io.Serializable {
      static final long serialVersionUID;
      private static final java.io.ObjectStreamField[] serialPersistentFields;
      !static !transient <fields>;
      private void writeObject(java.io.ObjectOutputStream);
      private void readObject(java.io.ObjectInputStream);
      java.lang.Object writeReplace();
      java.lang.Object readResolve();
  }
  -keepclassmembers class * {
      @android.webkit.JavascriptInterface <methods>;
  }

  # Pangle
  -keep class com.bytedance.sdk.** { *; }
  -keep class com.bykv.vk.openvk.component.video.api.** { *; }

  # Tapjoy
  -keep class com.tapjoy.** { *; }
  -keep class com.moat.** { *; }
  -keepattributes JavascriptInterface
  -keepattributes *Annotation*
  -keep class * extends java.util.ListResourceBundle {
  protected Object[][] getContents();
  }
  -keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
  public static final *** NULL;
  }
  -keepnames @com.google.android.gms.common.annotation.KeepName class *
  -keepclassmembernames class * {
  @com.google.android.gms.common.annotation.KeepName *;
  }
  -keepnames class * implements android.os.Parcelable {
  public static final ** CREATOR;
  }
  -keep class com.google.android.gms.ads.identifier.** { *; }
  -dontwarn com.tapjoy.**

ADOP 測試廣告金鑰

必須使用 ADOP 發放的廣告金鑰。

    // ANDROID 환경
    public static string adopAppDomain =                    "common-serving-bidmad.adop.co.kr";
    public static string rewardVideoUnitId =                "7d9a2c9e-5755-4022-85f1-6d4fc79e4418";
    public static string InterstitialAdUnitId =             "e9acd7fc-a962-40e4-aaad-9feab1b4f821";
    public static string AdaptiveBannerAdUnitId =           "944fe870-fa3a-4d1b-9cc2-38e50b2aed43";

    // IOS 환경
    public static string adopAppDomain =                    "common-serving-bidmad.adop.co.kr";
    public static string rewardVideoUnitId =                "29e1ef67-98d2-47b3-9fa2-9192327dd75d";
    public static string InterstitialAdUnitId =             "228b95a9-6f42-46d8-a40d-60f17f751eb1";
    public static string AdaptiveBannerAdUnitId =           "1c3e3085-333f-45af-8427-2810c26a72fc";

    // 기타 환경 (모바일이 아닌 환경은 미지원)
    public static string adopAppDomain = "NotSuport";
    public static string rewardVideoUnitId = "NotSuport";
    public static string InterstitialAdUnitId = "NotSuport";
    public static string AdaptiveBannerAdUnitId = "NotSuport";

Hive AdKit 初始化

要初始化 ADOP 广告,必须发放 adopAppDomain。发放的 adopAppDomain 必须作为 ADOP 广告初始化方法的参数使用。

Warning

從 AdKit 1.5.1 版本開始,之前使用的 AppKey 已更改為 AppDomain。AppDomain 與舊的 AppKey 不兼容,因此要初始化 Hive AdKit,您必須重新獲取 AppDomain。 有關 AppDomain 的信息,請聯繫 TechLabs 平台業務部運營團隊。

Note

執行初始化時,如果是歐洲及英國(EEA & UK)地區,GDPR 同意彈出窗口將自動顯示。在其他地區將直接執行初始化。

Warning

如果使用Hive SDK,則必須在完成Hive AdKit初始化後執行AuthV4.setup。如果在顯示ATT(應用程序追蹤透明度)同意通知後出現GDPR同意畫面,則應用可能會在Apple應用審核中被拒絕。

  • 如果遊戲針對歐洲和英國(EEA & UK)地區,請確保GDPR同意彈出窗口符合GDPR消息撰寫指南的要求。
  • // 상용 배포시
    HIVEAdKit.InitializeWithShowGDPRConsent(adopAppDomain, false, null, consentState => {
        /* 
        동의 = 1, 비동의 = 0, 알수없음 = -1, 필요없음 = -2
        초기화 완료 콜백으로 GDPR 동의 상태 결과 값 consentState가 전달됩니다. 결과값에 따른 별도 처리가 필요하지 않습니다. 
        */
        Debug.Log(TAG + "::InitializeWithShowGDPRConsent consentState : " + consentState);
    });
    
    // GDPR 테스트 사용시
    HIVEAdKit.GDPR.Reset();
    HIVEAdKit.InitializeWithShowGDPRConsent(adopAppDomain, true, testDeviceId, consentState => {
        /* 
        동의 = 1, 비동의 = 0, 알수없음 = -1, 필요없음 = -2
        초기화 완료 콜백으로 GDPR 동의 상태 결과 값 consentState가 전달됩니다. 결과값에 따른 별도 처리가 필요하지 않습니다. 
        */
        Debug.Log(TAG + "::InitializeWithShowGDPRConsent consentState : " + consentState);
    });
    

使用 Callback

要使用回调,必须将BidmadManager注册为GameObject。

GameObject bidmadManager = new GameObject("BidmadManager");
bidmadManager.AddComponent<BidmadManager>();
DontDestroyOnLoad(bidmadManager);

附加信息设置功能

// 遊戲數據範例
[Serializable]
public class SendInfo 
{
    public int level;
    public int gold;
}
SendInfo addtionalInfo = new SendInfo();
addtionalInfo.level = 1;
addtionalInfo.gold = 100;

// 以 JSON 物件形式傳送
HIVEAdKit.SetAdditionalInfo(JsonUtility.ToJson(addtionalInfo));

獎勵型廣告

在觀看廣告超過一定時間後會給予獎勵的獎勵型廣告。一次只能加載一個廣告。

    // Set Event Callback
    EventHandlers eventHandlers = new EventHandlers.Builder()
                                                   .OnAdLoaded(OnAdLoadedCB)
                                                   .OnAdOpening(OnAdOpeningCB)
                                                   .OnAdClosed(OnAdClosedCB)
                                                   .OnAdFailed(OnAdFailedCB)
                                                   .OnAdReward(OnAdRewardCB)
                                                   .Build();
    
    // Create RewardVideoAd Instance
    RewardVideoAd = HIVEAdKit.RewardVideo.Initialize(rewardVideoUnitId, eventHandlers);
    
    // Load RewardVideoAd
    HIVEAdKit.RewardVideo.LoadAd(RewardVideoAd, "Unity-RewardVideo-Load-AdPlacementInfo");
    
    // Show RewardVideoAd
    if( HIVEAdKit.RewardVideo.IsLoaded(RewardVideoAd) ) {
       HIVEAdKit.RewardVideo.Show(RewardVideoAd, "Unity-RewardVideo-Show-AdPlacementInfo");
    }
    

插頁式廣告

佔據整個螢幕的全屏廣告。

    // Set Event Callback
    EventHandlers eventHandlers = new EventHandlers.Builder()
                                                   .OnAdLoaded(OnAdLoadedCB)
                                                   .OnAdOpening(OnAdOpeningCB)
                                                   .OnAdClosed(OnAdClosedCB)
                                                   .OnAdFailed(OnAdFailedCB)
                                                   .OnAdClick(OnAdClickCB)
                                                   .Build();
    
    // Create InterstitialAd Instance                                               
    InterstitialAd = HIVEAdKit.Interstitial.Initialize(InterstitialAdUnitId, eventHandlers);
    
    // Load InterstitialAd
    HIVEAdKit.Interstitial.LoadAd(InterstitialAd, "Unity-Interstitial-Load-AdPlacementInfo");
    
    // Show InterstitialAd
    if( HIVEAdKit.Interstitial.IsLoaded(InterstitialAd) ) {
       HIVEAdKit.Interstitial.Show(InterstitialAd, "Unity-Interstitial-Show-AdPlacementInfo");
    }
    

自適應橫幅類型廣告

這是一個佔據螢幕部分的滾動橫幅。您可以輸入 BannerPosition 值或特定的 yPos 值來調整橫幅位置。 當輸入 yPos 值以調整橫幅位置時,橫幅位置會在底部對齊狀態下向上移動指定的 yPos 值。

// BannerPosition을 사용하는 예제입니다.
// Set Event Callback
EventHandlers eventHandlers = new EventHandlers.Builder()
                                               .OnAdLoaded(OnAdLoadedCB)
                                               .OnAdClosed(OnAdClosedCB)
                                               .OnAdFailed(OnAdFailedCB)
                                               .OnAdClick(OnAdClickCB)
                                               .Build();

// Create AdaptiveBanner Instance at Top of View
AdaptiveBannerAd = HIVEAdKit.AdaptiveBanner.Initialize(AdaptiveBannerAdUnitId, HIVEAdKit.AdaptiveBanner.BannerPosition.Top, eventHandlers);

// Create AdaptiveBanner Instance at Bottom of View
AdaptiveBannerAd = HIVEAdKit.AdaptiveBanner.Initialize(AdaptiveBannerAdUnitId, HIVEAdKit.AdaptiveBanner.BannerPosition.Bottom, eventHandlers);

// Automatic Load & Show AdaptiveBanner
HIVEAdKit.AdaptiveBanner.LoadAd(AdaptiveBannerAd, "Unity-AdaptiveBanner-Load-AdPlacementInfo");

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


// yPos 값을 지정하여 사용하는 예제입니다.
// Set Event Callback
EventHandlers eventHandlers = new EventHandlers.Builder()
                                               .OnAdLoaded(OnAdLoadedCB)
                                               .OnAdClosed(OnAdClosedCB)
                                               .OnAdFailed(OnAdFailedCB)
                                               .OnAdClick(OnAdClickCB)
                                               .Build();

// Set yPos
var yPos  = 100;
AdaptiveBannerAd = HIVEAdKit.AdaptiveBanner.Initialize(AdaptiveBannerAdUnitId, yPos, eventHandlers);

// Automatic Load & Show AdaptiveBanner
HIVEAdKit.AdaptiveBanner.LoadAd(AdaptiveBannerAd, "Unity-AdaptiveBanner-Load-AdPlacementInfo");

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


測試廣告

在開發過程中,設定測試廣告的點擊不會向廣告主收費是很重要的。如果在非測試模式下過多點擊廣告,將會被視為無效活動,這可能導致該帳戶被舉報,因此請小心。測試廣告的使用方法可以在Google 開發者網站上查看。

移除

Hive 若要移除 AdKit for ADOP,請刪除以下列表中的 Unity 專案內的資料夾。

    • 資產/Bidmad
    • 資產/HIVEAdKit
    • 資產/HIVEAdKit_範例