AdKit Unity for DARO¶
AdKit Unity for DARO is a Unity advertising module developed by applying the DARO API. When used with the SDK or individual modules, logs are sent to the analytics server, allowing you to skip separate advertising analysis work. Additionally, using AdKit Unity for DARO allows SDK users to fix errors and reduce trial and error that occur when applying Unity packages provided by DARO.
This guide explains how to install AdKit Unity for DARO, configure prerequisites for each OS Unity environment, and use each function.
Installation or update¶
If you are using AdKit for DARO for the first time, install it in the following order.
Alternatively, if you want to update an existing AdKit installation, delete the existing installed version and install the latest version of AdKit for DARO in the following order.
- Download and install the latest version of AdKit for DARO.
-
In the Unity toolbar, go to Assets > Import Package > Custom Package..., select the .unitypackage file, and click Import.
-
After import completion, verify that Hive AdKit and DARO-related files and folders have been created under the Assets folder.
-
Download and install the latest version of EDM4U. EDM4U is included in Hive SDK v4. If you are using Hive SDK v4, please skip this step.
Delete¶
To delete Hive AdKit for DARO, delete the following folders in your Unity project:
- Assets/HIVEAdKit
- Assets/HIVEAdKit_Example
Prerequisites configuration¶
After completing the installation of AdKit for DARO, as a prerequisite configuration step to apply it, add DARO key values for each OS and verify build settings.
Android¶
Add key values downloaded from the DARO dashboard to Android-based Unity projects.
- Copy the downloaded android-daro-key.txt file into the HIVEAdKit/Plugins/Android folder.
- The android-daro-key.txt file can be downloaded by clicking the Download button for 'Key File' on the DARO Dashboard - Apps screen.
- Add
daroAppKey
to gradleTemplage.properties as follows:- The daroAppKey can be found through 'DARO App Key' on the DARO Dashboard - Apps screen.
- The daroAppKey can be found through 'DARO App Key' on the DARO Dashboard - Apps screen.
iOS¶
Add key values downloaded from the DARO dashboard to iOS-based Unity projects.
- Copy the downloaded ios-daro-key.txt file into the HIVEAdKit/Plugins/iOS folder.
- The ios-daro-key.txt file can be downloaded from the DARO dashboard.
- In the HIVEAdKit/Editor/iOSAdKitPostBuildProcessor.cs file, uncomment the commented Google Admob appId and Daro App Key sections and add the internal values as shown below:
// Set GADApplicationIdentifier (Please contact Daro for your own ADMOB APPID) //rootDict.SetString("GADApplicationIdentifier", "YOUR GOOGLE ADMOB APPID"); // Set DaroAppKey (Please contact DARO for your own Daro App Key) //rootDict.SetString("DaroAppKey", "YOUR Daro App Key");
- Google Admob appId and Daro App Key can be downloaded from the DARO dashboard.
iOS build settings verification¶
When building iOS projects, a UnityFramework target that operates as a DynamicFramework is created.
-
EDM4U configuration (based on 1.2.179) In Unity's iOS Resolver Settings (menu: Assets > External Dependency Manager > iOS Resolver > Settings), verify that the static_framework build setting is configured.
-
Build the project. After build completion, open the Podfile from the generated project root path to verify file settings.
Warning
Before building a production service that applies AdKit Unity, you must delete the Assets/HIVEAdKit_Example folder. HIVEAdKit Example settings may be included.
DARO Proguard configuration¶
Proguard rules are included in the library AAR file and distributed, so they are automatically configured without separate settings.
Usage guide¶
This section provides guidance on settings and API call methods for using AdKit Unity for DARO features.
AdKit initialization¶
- If your game targets Europe and UK (EEA & UK) regions, you must initialize AdKit after calling the
ShowConsentUI
API to display the GDPR consent popup. If you only provide services domestically, call theHIVEAdKit.Initialize
API to proceed with initialization directly.
All API features provided by HIVEAdKit must be called from Unity's main thread.
using hive.adkit.daro;
// Call GDPR popup
public void ShowGDPR(string noticeId)
{
HIVEAdKit.ShowConsentUI(noticeId, () =>
{
initSdk();
});
}
// Hive AdKit initialization
public void initSdk()
{
HIVEAdKit.Initialize(isSuccess =>
{
if (isSuccess)
Debug.Log("AdKit SDK initialization successful!");
else
Debug.Log("AdKit SDK initialization failed!");
});
}
Using callbacks¶
To use callback functions, you must call HIVEAdKit.InitPlugin
to register AdKitCallbackManager as a GameObject.
Call this in the Start code block when the app starts.
using hive.adkit.daro;
void Start()
{
HIVEAdKit.InitPlugin(); // Create game object for Hive AdKit callback registration
}
Setting additional information¶
You can set additional information. The implementation code is as follows:
using hive.adkit.daro;
[Serializable]
public class SendInfo
{
public int level;
public int gold;
}
SendInfo addtionalInfo = new SendInfo();
public void SetAdditionalInfo()
{
addtionalInfo.level = 1;
addtionalInfo.gold = 100;
// Send as JSON Object format
HIVEAdKit.SetAdditionalInfo(JsonUtility.ToJson(addtionalInfo));
}
Rewarded advertising feature¶
Provides rewarded advertising features that give rewards when watching ads for a certain amount of time or more. Only one ad can be loaded at a time. The code to implement the rewarded advertising feature is as follows:
using hive.adkit.daro;
private HIVEAdKit.RewardVideo RewardVideoAd = null;
public void InitRewardedAd()
{
// Set Event Callback
EventHandlers eventHandlers = new EventHandlers.Builder()
.OnAdLoaded(OnRewardVideoAdLoadedCB)
.OnAdOpening(OnRewardVideoAdOpeningCB)
.OnAdClosed(OnRewardVideoAdClosedCB)
.OnAdFailed(OnRewardVideoAdFailedCB)
.OnAdReward(OnRewardVideoAdRewardCB)
.OnAdClick(OnRewardVideoAdClickCB)
.OnAdPaidEvent(OnRewardVideoAdPaidEventCB)
.Build();
// Create RewardVideoAd Instance
RewardVideoAd = HIVEAdKit.RewardVideo.Initialize(rewardVideoUnitId, eventHandlers);
}
public void LoadRewardedAd()
{
// Load RewardVideoAd
HIVEAdKit.RewardVideo.Load(RewardVideoAd, "Unity-RewardVideo-Load-AdPlacementInfo");
}
public void ShowRewardedAd()
{
// Show RewardVideoAd
if( HIVEAdKit.RewardVideo.IsLoaded(RewardVideoAd) ) {
HIVEAdKit.RewardVideo.Show(RewardVideoAd, "Unity-RewardVideo-Show-AdPlacementInfo");
}
}
public void DestroyRewardedAd()
{
// Destroy RewardVideoAd
HIVEAdKit.RewardVideo.Destroy(RewardVideoAd);
RewardVideoAd = null;
}
Interstitial advertising feature¶
Provides interstitial advertising features that occupy the entire screen. The implementation code is as follows:
using hive.adkit.daro;
private HIVEAdKit.Interstitial InterstitialAd = null;
public void InitRewardedAd(string unitId)
{
// Set Event Callback
EventHandlers eventHandlers = new EventHandlers.Builder()
.OnAdLoaded(OnInterstitialAdLoadedCB)
.OnAdOpening(OnInterstitialAdOpeningCB)
.OnAdClosed(OnInterstitialAdClosedCB)
.OnAdFailed(OnInterstitialAdFailedCB)
.OnAdClick(OnInterstitialAdClickCB)
.OnAdPaidEvent(OnInterstitialAdPaidEventCB)
.Build();
// Create InterstitialAd Instance
InterstitialAd = HIVEAdKit.Interstitial.Initialize(unitId, eventHandlers);
}
public void LoadInterstitialAd()
{
// Load InterstitialAd
HIVEAdKit.Interstitial.Load(InterstitialAd, "Unity-Interstitial-Load-AdPlacementInfo");
}
public void ShowInterstitialAd()
{
// Show InterstitialAd
if( HIVEAdKit.Interstitial.IsLoaded(InterstitialAd) ) {
HIVEAdKit.Interstitial.Show(InterstitialAd, "Unity-Interstitial-Show-AdPlacementInfo");
}
}
public void DestroyInterstitialAd()
{
// Destroy InterstitialAd
HIVEAdKit.Interstitial.Destroy(InterstitialAd);
InterstitialAd = null;
}
Banner advertising feature¶
Provides banner advertising features that occupy part of the screen. You can adjust the banner position to the top or bottom of the screen by entering BannerPosition
.
Banner ads do not receive the OnAdClosed()
callback.
using hive.adkit.daro;
private HIVEAdKit.Banner BannerAd = null;
public void InitBannerAd(string unitId)
{
// Set Event Callback
EventHandlers eventHandlers = new EventHandlers.Builder()
.OnAdLoaded(OnBannerAdLoadedCB)
.OnAdFailed(OnBannerAdFailedCB)
.OnAdClick(OnBannerAdClickCB)
.OnAdPaidEvent(OnBannerAdPaidEventCB)
.Build();
BannerAd = HIVEAdKit.Banner.Initialize(unitId, BannerPosition.Bottom, eventHandlers);
}
public void LoadBannerAd()
{
// Automatic Load & Show BannerAd
HIVEAdKit.AdaptiveBanner.Load(BannerAd, "Unity-AdaptiveBanner-Load-AdPlacementInfo");
}
public void DestroyBannerAd()
{
// Destroy BannerAd
HIVEAdKit.Banner.Destroy(BannerAd);
BannerAd = null;
}