Unity
Hive AdKit for ADOP: Unity¶
Hive AdKit for ADOP (hereinafter referred to as AdKit for ADOP) uses the ADOP API and has been developed according to the ADOP development guide. When using AdKit for ADOP with the Hive SDK or individual modules, logs are sent to the analytics server, allowing you to skip separate advertising analysis tasks. This guide is written as an AdKit for ADOP application guide to help Hive SDK users correct errors that occur during the process of applying the Unity package provided by ADOP and to reduce trial and error for ease of use. Learn about the versions that support AdKit for ADOP and how to apply it.
Installation¶
- Download and install the latest version of AdKit for ADOP.
- In the Unity toolbar, select Assets > Import Package > Custom Package..., choose the .unitypackage file, and click Import.
- After the import is complete, check if the Hive AdKit and ADOP related files and folders have been created under the Assets folder.
- Download and install the latest version of EDM4U here.
- EDM4U is included in Hive SDK v4. If you are using Hive SDK v4, you can skip this step.
Warning
When conducting AdKit tests during development, you must apply the test ad key.
Update¶
Please delete the AdKit you are using and install the latest version to update.
Settings\nPlease set up AdKit according to the guide for each operating system below.¶
- Android
Add the `AdMobId` value in the format of ca-app-pub-XXXXX~YYYYY to the Assets/Plugins/Android/AndroidManifest.xml file created in the Unity project. - iOS
AddGADApplicationIdentifier
to the Info.plist file of the Xcode project generated during the Unity build, and enter the AdMobId value in the format ca-app-pub-XXXXX~YYYYY as a String type. For iOS 14 and above, please add the list of ADOP's SKAdNetwork to the Info.plist file. (It will be automatically added during the build using the Assets/Bidmad/Editor/BidmadPostProcessBuild.cs file.)
Apply¶
iOS¶
A target called UnityFramewok that operates as a DynamicFramework is created when building the iOS project.
-
EDM4U Settings (based on 1.2.179)
Check if the static_framework build setting is configured in Unity's iOS Resolver Settings (Menu: Assets > External Dependency Manager > iOS Resolver > Settings).
In the Assets/HIVEAdKit/Editor/AdKitPostprocess.cs file, uncomment the dynamicFramework
Import. The comment location is as follows.
```cs
(string Name, string Source)[] dynamicFrameworks = {
// ("AdFitSDK.framework","Pods/AdFitSDK/Frameworks"),
// ("AdPopcornSSP.xcframework", "Pods/AdPopcornSSP"),
// ("AppLovinSDK.xcframework", "Pods/AppLovinSDK/applovin-ios-sdk-13.0.0"),
// ("BidmadSDK.xcframework", "Pods/BidmadSDK"),
// ("NaverAdsServices.xcframework", "Pods/Naver-Ads-Services/NaverAdsServices/xcframework"),
("OMSDK_Navercorp.xcframework","Pods/NAMSDK/NAMSDK/xcframework/libraries"),
("OMSDK_Pubmatic.xcframework","Pods/OpenWrapSDK/OpenWrapSDK"),
// ("OMSDK_Teadstv.xcframework", "Pods/TeadsSDK/Frameworks"),
// ("TeadsSDK.xcframework", "Pods/TeadsSDK/Frameworks"),
};
```
Uncommenting is only done when checking static_framework and building. If you uncomment to activate the above code when using a Dynamic Framework, a crash may occur.
-
Build the project. After the build is complete, open the Podfil in the generated 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.10.0' pod 'BidmadAdpieAdapter', '1.6.1.10.0' pod 'BidmadAdPopcornAdapter', '2.6.5.10.0' pod 'BidmadAppLovinAdapter', '13.0.0.10.0' pod 'BidmadAtomAdapter', '1.0.0.10.0' pod 'BidmadFyberAdapter', '8.3.2.10.0' pod 'BidmadGoogleAdManagerAdapter', '11.10.0.10.0' pod 'BidmadGoogleAdMobAdapter', '11.10.0.10.0' pod 'BidmadIronSourceAdapter', '8.3.0.0.10.0' pod 'BidmadPangleAdapter', '6.2.0.7.10.0' pod 'BidmadPartners/AdMobBidding', '1.0.5' pod 'BidmadPubmaticAdapter', '3.2.0.10.0' pod 'BidmadSDK', '6.11.0' pod 'BidmadTeadsAdapter', '5.0.27.10.0' pod 'BidmadUnityAdsAdapter', '4.12.3.10.0' pod 'BidmadVungleAdapter', '7.4.1.10.0' pod 'HiveAdKit_ADOP_PrivacyInfo', '1.5.1' pod 'OpenBiddingHelper', '6.11.0' end target 'Unity-iPhone' do end use_frameworks!
After running pod install
, open the workspace and proceed with the Xcode settings. When checking the General tab, the necessary Dynamic Frameworks are automatically embedded as shown below.
Note
[Issues related to Facebook SDK distribution]
The Facebook SDK is only provided in DynamicFramework format, while the advertising module is only provided in StaticFramework format. However, the Podfile settings only support one of these two methods. Therefore, to apply Facebook when building in Unity, additional settings must be configured according to the method below to resolve conflicts between the Facebook SDK and the advertising module.
Add additional library dependencies to the main target of the Xcode build.
Add the FBSDKAMKit, FBSDKCoreKit_Baseic, FBSDKCoreKit, FBSDKLoginKit, and FBSDKShareKit frameworks as DynamicFrameworks.
???+ note To obtain information for filling out the personal information survey form when distributing the app, please refer to the Privacy Survey Guide.
ADOP Proguard Configuration¶
If you are using Proguard, you need to add the following ADOP Proguard settings.
-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 Test Ad Key¶
You must use the ad key issued by 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 Initialization¶
To initialize ADOP advertising, it is mandatory to issue adopAppDomain
. The issued adopAppDomain
must be used as an argument in the ADOP advertising initialization method.
Warning
Starting from AdKit version 1.5.1, the previously used AppKey has been changed to AppDomain. The AppDomain is not compatible with the existing AppKey, so you will need to obtain a new AppDomain for Hive AdKit initialization. For information regarding AppDomain, please contact the Tech Labs Platform Division Operations Team.
Note
When performing initialization, a GDPR consent popup will automatically appear if you are in the Europe and UK (EEA & UK) regions. In other regions, initialization will be performed immediately.
Warning
If you are using the Hive SDK, you must execute AuthV4.setup
after completing the initialization of Hive AdKit. If the GDPR consent screen appears after displaying the ATT (App Tracking Transparency) consent notification, your app may be rejected during the Apple app review.
- If the game targets the EEA & UK regions, make sure the GDPR consent popup is set according to the GDPR message creation guide.
// 상용 배포시
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);
});
Using Callback¶
To use the Callback, you need to register BidmadManager as a GameObject.
GameObject bidmadManager = new GameObject("BidmadManager");
bidmadManager.AddComponent<BidmadManager>();
DontDestroyOnLoad(bidmadManager);
Additional Information Settings¶
// GameData Example
[Serializable]
public class SendInfo
{
public int level;
public int gold;
}
SendInfo addtionalInfo = new SendInfo();
addtionalInfo.level = 1;
addtionalInfo.gold = 100;
// Sent in JSON Object format
HIVEAdKit.SetAdditionalInfo(JsonUtility.ToJson(addtionalInfo));
Rewarded Type Ads¶
This is a rewarded ad that provides rewards for watching ads for a certain period of time. Only one ad can be loaded 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 type ads¶
These are full-screen advertisements that cover the entire screen.
// 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 Advertisement¶
It is a rolling banner that occupies part of the screen. You can adjust the banner position by entering the BannerPosition value or a specific yPos value. When adjusting the banner position by entering the yPos value, the banner position moves up by the specified yPos value from the Bottom alignment.
// 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);
Test Ad¶
During development, it is important to set it up so that clicking on test ads does not incur costs for the advertiser. If you click on ads excessively while not in test mode, it may be recognized as invalid activity, which could lead to the account being reported, so please be cautious. You can find information on how to use test ads on the Google Developers site.
Delete¶
Hive To remove AdKit for ADOP, delete the folders in the Unity projects listed below.
-
- Assets/Bidmad
- Assets/HIVEAdKit
- Assets/HIVEAdKit_Example