Skip to content

Unity

AdKit for ADOP: Unity

AdKit for ADOP (hereinafter, AdKit for ADOP) is an advertisement module that uses ADOP's API and develops by following the guideline from ADOP. Using AdKit with Hive SDK, log data is sent to Analytics server so that you can skip analyzing an advertisement.

This guide explains how to implement AdKit and makes it easier by fixing errors that occur during integrating the Unity package. Read this page for using AdKit as well as support SDK.

Installation

  1. Download and install the latest version of AdKit for ADOP here.
  2. In the Unity toolbar, select the .unitypackage file under Assets > Import Package > Custom Package... and click Import.

  3. After import, check if AdKit and ADOP related files and folders have been created under the Assets folder.

  4. Download and install the latest version of EDM4U here.
    • If you're using Hive SDK v4, which includes EDM4U, you can skip this step.
Warning

When testing AdKit during development, you must apply the test advertisement key.

Update

Uninstall the AdKit you are using and install the latest version to update.

Setting

Follow the guide below for each platform to configure AdKit.

Android

Add AdMobId, which is formatted in ca-app-pub-XXXXX~YYYYY, to the Assets/Plugins/Android/AndroidManifest.xml file generated in the Unity project.

    <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

Add GADApplicationIdentifier to Info.plist of the Xcode project generated in Unity build, and enter AdMobId, which is formatted in ca-app-pub-XXXXX~YYYYY, as string type.

<key>GADApplicationIdentifier</key>
<string>ca-app-pub-XXXXX~YYYYY</string>

On iOS 14 and higher, add SKAdNetworkItems to Info.plist. (When using the Assets/Bidmad/Editor/BidmadPostProcessBuild.cs file to build, SKAdNetworkIdentifier will add automatically.)

How to use

iOS

When you build an iOS project, Unity generates the UnityFramework target that behaves with DynamicFramework.

  1. Setting EDM4U (Based on 1.2.179) Make sure that set up to build static_framwork in iOS Resolver Settings (menu: Assets > External Dependency Manager > iOS Resolver > Settings) of Unity editor.

  1. In Assets/HIVEAdKit/Editor/AdKitPostprocess.cs file, uncomment the lines that import dynamicFramework. The location of the lines are as follows.

(string Name, string Source)[] dynamicFrameworks = {
   //("FBLPromises.xcframework", "Libraries/Bidmad/Plugins/iOS"), 
   ("OMSDK_Pubmatic.xcframework","Pods/OpenWrapSDK/OpenWrapSDK"),
   //("ADOPUtility.xcframework", "Pods/ADOPUtility"),
   //("OMSDK_Teadstv.xcframework", "Pods/TeadsSDK/Frameworks"), 
   //("TeadsSDK.xcframework", "Pods/TeadsSDK/Frameworks"), 
   //("IASDKCore.xcframework", "Pods/Fyber_Marketplace_SDK/IASDKCore"),
   //("AdFitSDK.framework","Pods/AdFitSDK/Frameworks")
};
Uncomment the lines only if static_framework is checked for the build. Uncommenting the lines above to activate them may cause conflicts when you use Dynamic Framework.

  1. Build the project. After the build is complete, open the Podfile in the project root path to check the file settings.
     source 'https://github.com/Com2uSPlatformCorp/HiveAdKit-iOS.git'
     source 'https://cdn.cocoapods.org/'

     platform :ios, '12.0'

     target 'UnityFramework' do
       pod 'BidmadAdFitAdapter', '3.12.7.4'
       pod 'BidmadADOPCoupangAdapter', '1.0.0.3'
       pod 'BidmadAppLovinAdapter', '12.2.1.0'
       pod 'BidmadAtomAdapter', '1.0.0.3'
       pod 'BidmadFyberAdapter', '8.2.6.0'
       pod 'BidmadGoogleAdManagerAdapter', '11.2.0.0'
       pod 'BidmadGoogleAdMobAdapter', '11.2.0.0'
       pod 'BidmadIronSourceAdapter', '7.8.0.0.0'
       pod 'BidmadPangleAdapter', '5.8.0.7.0'
       pod 'BidmadPartners/AdMobBidding', '1.0.3'
       pod 'BidmadPubmaticAdapter', '3.2.0.3'
       pod 'BidmadSDK', '6.6.1'
       pod 'BidmadTeadsAdapter', '5.0.27.3'
       pod 'BidmadUnityAdsAdapter', '4.9.3.0'
       pod 'BidmadVungleAdapter', '7.2.2.0'
       pod 'HiveAdKit_ADOP_PrivacyInfo', '1.4.6'
       pod 'OpenBiddingHelper', '6.6.1'
     end
     target 'Unity-iPhone' do
     end
     use_frameworks!
  1. After running pod install, proceed with the Xcode settings by opening the workspace. When checking the General tab, the required Dynamic /Frameworks are automatically embedded as follows:

Note

[An issue relating to Facebook SDK deployment] Facebook SDK provides a build as a dynamic framework, and advertisement modules provide it as a static framework however, Podfile supports only one of both frameworks. Therefore, when you build on Unity and apply Facebook, follow the additional setting below to resolve crashes between Facebook SDK and the advertisement module.

Add additional library dependencies on the TARGET list of the Xcode build.


Add FBSDKAMKit, FBSDKCoreKit_Baseic, FBSDKCoreKit, FBSDKLoginKit, and FBSDKShareKit frameworks as a dynamic framework.


Note

Please refer to the Privacy Survey Guide for information on completing the privacy survey form when distributing your app.

ADOP Proguard settings

If you are using Proguard, add the ADOP Proguard Settings as below.

  -keep class com.adop.sdk.** { *; }
  -keep class ad.helper.openbidding.** { *; }
  -keep class com.adop.adapter.fc.** { *; }
  -keep class com.adop.adapter.fnc.** { *; }
  -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 ;
      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 ;
  }

  # 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.**

Test ad key in ADOP

Using a test ad key that ADOP issued is required.

// ANDROID Environment
    public static string adopAppKey =                       "6933aab2-7f78-11ed-a117-026864a21938";
    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 Environment
    public static string adopAppKey =                       "6b097551-7f78-11ed-a117-026864a21938";
    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";

// Other Environments (Only the mobile envs supported.)
    public static string adopAppKey = "NotSuport";
    public static string rewardVideoUnitId = "NotSuport";
    public static string InterstitialAdUnitId = "NotSuport";
    public static string AdaptiveBannerAdUnitId = "NotSuport";

Initialize AdKit

In order to initialize ADOP ads, adopAppKey must be issued. The issued adopAppKey must be used as an ADOP advertisement initialization method argument.

Note

When performing a reset, a GDPR consent pop-up will automatically appear if you are in the EEA & UK region. In other regions, perform a reset immediately. If your game targets the EEA & UK region, make sure your GDPR consent pop-up is set up according to the GDPR messaging guide.

// For commercial distribution
HIVEAdKit.InitializeWithShowGDPRConsent(adopAppKey, false, null);

// When testing GDPR
HIVEAdKit.GDPR.Reset();
HIVEAdKit.InitializeWithShowGDPRConsent(adopAppKey, true, testDeviceId);

Callback

To use Callback, BidmadManager must be registered as GameObject.

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

Advanced settings

// 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));

Rewarded ads

Rewarded ads reward a user who watched a video for a period of time, and is able to load one ad at a time.

// 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");
}

Interstitial ads

Interstitial ads are full-screen ads that cover the interface of game.

// 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");
}

Adaptive Banner type

Adaptive Banner type ads are a type of rolling banner that occupies a spot on screen. You can adjust the banner position with the BannerPosition or an yPos value.

If you provide yPos to adjust the banner position, the banner will be aligned at the bottom of the screen and then will move up by the yPos value you specify.

// the example codes using the 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);
// This example shows adjusting the banner position with specifiying the yPos value.
// 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);

Test ads

It is important for advertiser not to be charged when test ad is clicked in development. If you click ads too much out of test mode, it is regarded as invalid action. Therefore, be aware not to be a target account to report.

Refer to the Google Developers to use a test ad.

Uninstallation

To uninstall AdKit for ADOP, remove the following folders within the Unity project.

  • Assets/Bidmad
  • Assets/HIVEAdKit
  • Assets/HIVEAdKit_Example