Hive AdKit for ADOP: Unity
Hive 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 Hive 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
- Download and install the latest version of AdKit for ADOP here.
- In the Unity toolbar, select the .unitypackage file under Assets > Import Package > Custom Package… and click Import.
- After import, check if Hive AdKit and ADOP related files and folders have been created under the Assets folder.
- Download and install the latest version of EDM4U here.
- If you’re using Hive SDK v4, which includes EDM4U, you can skip this step.
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.
123456<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
AddGADApplicationIdentifier
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.
12<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.
- 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.
-
In Assets/HIVEAdKit/Editor/AdKitPostprocess.cs file, uncomment the lines that import
dynamicFramework
. The location of the lines are as follows.1234567891011(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.
-
Build the project. After the build is complete, open the Podfile in the project root path to check the file settings.
1234567891011121314151617181920212223242526272829source 'https://github.com/Com2uSPlatformCorp/HiveAdKit-iOS.git'source 'https://cdn.cocoapods.org/'platform :ios, '12.0'target 'UnityFramework' dopod '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'endtarget 'Unity-iPhone' doenduse_frameworks! -
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:
ADOP Proguard Settings
If you are using Proguard, add the ADOP Proguard Settings as below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
-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 <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.** |
Test Ad Key in ADOP
Using a test ad key that ADOP issued is required.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
// 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 Hive AdKit
In order to initialize ADOP ads, adopAppKey
must be issued. The issued adopAppKey
must be used as an ADOP advertisement initialization method argument.
1 2 3 4 5 6 |
// 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.
1 2 3 4 |
GameObject bidmadManager = new GameObject("BidmadManager"); bidmadManager.AddComponent<BidmadManager>(); DontDestroyOnLoad(bidmadManager); |
Advanced Settings
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// 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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
// 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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
// 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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
// 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); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
// 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 Hive AdKit for ADOP, remove the following folders within the Unity project.
-
- Assets/Bidmad
- Assets/HIVEAdKit
- Assets/HIVEAdKit_Example