Skip to content

AdKit Unity for DARO

'AdKit Unity for DARO' is a Unity advertising module developed with the DARO API. When used with Hive SDK or individual modules, it sends logs to the analytics server, eliminating the need for separate advertising analysis. It also reduces errors and trial and error for Hive SDK users when applying DARO's Unity packages.

This guide explains how to install 'AdKit Unity for DARO', configure it for each OS-specific Unity environment, and use its features.

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.

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

  3. After import completion, verify that Hive AdKit and DARO-related files and folders have been created under the Assets folder.

  4. 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 'AdKit for DARO', delete the following folders in your Unity project:

  • Assets/HIVEAdKit
  • Assets/HIVEAdKit_Example

Deleting these folders preserves the Integration Key stored in the Assets/HiveAdKitDaroKey folder. If the 'Integration Key' changes, also delete the Assets/HiveAdKitDaroKey folder and enter the new key.

Prerequisites configuration

Enter the 'Integration Key' for the platform you want to build in the Unity project.

Integration Key

To configure the 'Integration Key', copy the value from the DARO dashboard and enter it in your Unity project. If you have used a version earlier than DARO 2.0 SDK, update the DARO dashboard first.

On DARO Dashboard - Apps, click Copy for Integration Key.

In Unity, enter the copied key under Hive > AdKit > DARO Settings. DARO issues a separate 'Integration Key' for Android and iOS, so enter each platform's key in the corresponding field.

The Unity editor saves the key in Assets/HiveAdKitDaroKey/HiveAdKitDaroSettings.json. The build fails if no key is entered for the platform you want to build.

Caution

Before building for production, delete the Assets/HIVEAdKit_Example folder to prevent HIVEAdKit Example settings from being included.

DARO Proguard configuration

Proguard rules are distributed in the library AAR file. The build applies these rules automatically, so no additional configuration is required.

Usage guide

This section explains how to configure and call APIs for 'AdKit Unity for DARO' features.

AdKit initialization

  • If your app targets Europe and the UK (EEA & UK), initialize AdKit after calling the ShowConsentUI API to display the GDPR consent popup. If your service is available only domestically, call the HIVEAdKit.Initialize API to initialize AdKit directly.
    As shown in the example below, all APIs 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 it 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 additionalInfo = new SendInfo();

public void SetAdditionalInfo()
{
    additionalInfo.level = 1;
    additionalInfo.gold = 100;

    // Send as a JSON Object
    HIVEAdKit.SetAdditionalInfo(JsonUtility.ToJson(additionalInfo));
}

Rewarded ad feature

'Rewarded ads' reward users who watch an ad for a specified amount of time. Only one ad can be loaded at a time. The implementation code for 'rewarded ads' 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 InitInterstitialAd(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;
}

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.Banner.Load(BannerAd, "Unity-Banner-Load-AdPlacementInfo");
}

public void DestroyBannerAd()
{
    // Destroy BannerAd
    HIVEAdKit.Banner.Destroy(BannerAd);
    BannerAd = null;
}

DARO example

Planet Explore uses the DARO ad module to optimize and deliver banner and interstitial ads. Download Planet Explore to see a real-world example of DARO ads in action.

Interstitial ad