Hive Adiz Unity

Hive Adiz Unity is an advertising module for Unity provided by Hive, making it easier to use the advertising features offered by AdMob. The types of ads offered by Hive Adiz Unity are as follows:

  • Interstitial Ads
  • Banner Ads
  • Native Ads
  • Rewarded Ads
  • Rewarded Interstitial Ads
  • App Open Ads

To install and use Hive Adiz Unity, follow the guide in order below.

Installation or Update

  1. Download the latest version of Hive Adiz here and unzip it.
  2. In Unity, go to Assets > Import Package > Custom Package…, select the .unitypackage file, and click Import.


  3. Check if Hive Adiz 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, you do not need to install EDM4U separately.

 

To update the currently used version of Adiz, delete Adiz and download and install the latest version.

Unity Setup

Android

Add the AdMobId value in the format of ca-app-pub-XXXXX~YYYYY to the Assets/Plugins/Android/AndroidManifest.xml file created in your Unity project.

 

To display video ads, hardware acceleration must be enabled. Add settings for hardware acceleration to the AndroidManifest.xml file. Adding it to the application tag will enable hardware acceleration for the entire application. Adding it to the activity tag will enable hardware acceleration only for specific Activity where you want to display ads.

 

Check Use Jetifier in Unity‘s Android Resolver Settings (Assets > External Dependency Manager > Android Resolver > Settings).

 

In the Player Settings > Player > Build settings screen, check the following three items.

 

If you are using Proguard, add the following settings.

 

Check your current version of Gradle. For a stable Android build, the Gradle version should be 6.7.1 or higher, and the Gradle plugin version should be 4.2.0 or higher. Here’s how to change the Gradle version and Gradle plugin version:

 

  1. Use the Custom Base Gradle Template.
    • Check Build Settings > Project Settings > Player > Custom Base Gradle Template.
    • Assets/Plugins/Android/baseProjectTemplate.gradle will be created.
  2. Change the Gradle Plugin version.
    • Open the file Assets/Plugins/Android/baseProjectTemplate.gradle and change the version like com.android.tools.build:gradle:4.2.0.
  3. Download the required version of Gradle, then unzip it in your desired path.
  4. Change the Gradle installation path in Unity.
    • Uncheck Preferences > External Tools > Gradle Installed with Unity.
    • Set the path where you unzipped Gradle.
  5. Check that the Target API Level is 33 or higher in Player > Other Settings > Identification > Target API Level before building.

iOS

Uncheck the static_framework build setting in Assets > External Dependency Manager > iOS Resolver > Settings.

  

Configure the Podfile created during the Unity build as follows.

 

Add the GADApplicationIdentifier key to the Info.plist file of the Xcode project created during the Unity build, and enter the AdMobId value (in the format ca-app-pub-XXXXX~YYYYY) as the key value. Or, you can uncomment the GADApplicationIdentifier setting line in the Assets/HiveAdiz/Editor/AdizPostProcess.cs file and add the AdMobId to automatically set it.

  

Additionally, for iOS 14 and above, refer to the Update your info.plist guide to add the SKAdNetwork list to the Info.plist file. The Assets/HiveAdiz/Editor/AdizPostProcess.cs file can be used to automatically add it to the Info.plist file during the build.

Test Mode Configuration

During the development phase, enable test mode to prevent charging advertisers when test ads are clicked. When test mode is activated, only test ads are displayed. In test mode, you can display test ads without entering the AdMob ad key in the Hive console. Disable test mode for commercial distribution.

Hive Adiz AppID Configuration

Set the Hive Adiz AppID registered in the Hive console AppCenter. If not set, the Package Name or Bundle ID will be used.

Hive Console Server Configuration

Configure the Hive console server you want to use. The default is REAL. Even if you use the commercial server, only test ads will be displayed if test mode is enabled.

  • Hive Test Console Server: ZoneType.TEST
  • Hive Sandbox Console Server: ZoneType.SANDBOX
  • Hive Commercial Console Server: ZoneType.REAL

Exposing User-Specific Ads

With the introduction of ATT (App Tracking Transparency) in iOS 14.5+, privacy protection has been strengthened. As a result, user-specific ads can only be exposed if the user consents to activity tracking in the ATT consent popup. To maximize ad revenue by exposing user-specific ads, it is necessary to create an IDFA (Identifier for Advertisers) message.
Create and publish your IDFA message following the guide on the AdMob dashboard.

Once the IDFA message is published on the AdMob dashboard, it will automatically be displayed during the initialization of Hive Adiz in iOS 14.5+. Clicking “Continue” in the IDFA message window will display the ATT consent popup.

If the user clicks “Allow” in the ATT consent popup, IDFA is activated, and user-specific ads will be displayed.

GDPR Consent Popup Display (Europe and UK)

If your game targets Europe and the UK (EEA & UK), it is required to display a GDPR (General Data Protection Regulation) consent popup. The GDPR consent popup will only be shown if the user’s device IP address is from Europe or the UK (EEA & UK). Hive Adiz supports Google‘s UMP (User Messaging Platform) for displaying the GDPR consent popup. To display the GDPR popup, you must create a GDPR message in the AdMob console and then initialize Hive Adiz. If you do not plan to serve your app in Europe or the UK, you may skip this step and proceed to initializing Hive Adiz.

Creating GDPR Message

Access the Google AdMob console to create the GDPR message. Before creating the GDPR message, refer to the GDPR message creation guide.

After creating the GDPR message, the GDPR consent popup will automatically be displayed during the initialization of Hive Adiz.

Implementing Options for GDPR Consent/Withdrawal

The GDPR consent popup should allow users to modify their consent at any time. For instance, users who initially did not consent to GDPR but wish to receive personalized ads may want to consent, or vice versa. To accommodate such scenarios, developers must implement functionality for users to either consent again or withdraw their previous consent. To implement GDPR consent/withdrawal functionality, follow these steps:

  1. Implement a button UI in your app to reload the GDPR consent popup window.
  2. When implementing the initialization of Hive Adiz, call isPrivacyOptionsRequired() to display the button UI above for users accessing from Europe and the UK, and not display it otherwise. If users from Europe and the UK press the button, call showPrivacyOptionsForm to reload the GDPR consent popup, allowing users to modify their consent for GDPR details at any time through a “Manage Options” button or similar within the app. The showPrivacyOptionsForm method provided below is for illustration purposes only and can be implemented in any form desired by the developer.
  3. Unity

GDPR 테스트 기기 설정

The GDPR consent popup is displayed only if the device’s IP address is from Europe or the UK. During development, you can force the GDPR consent popup to display regardless of the device IP address for testing purposes by setting up GDPR test devices. Follow the steps below to set up GDPR test devices:

  1. Initialize Hive Adiz. The purpose of this initialization is to check the test device ID, so you don’t need to create a GDPR consent message in advance.
  2. Print Android Studio log or Xcode log to get the device ID. The following log is an example.

    Android:
    33BE2250B43518CCDA7DE426D04EE231 in Use new ConsentDebugSettings.Builder().addTestDeviceHashedId("33BE2250B43518CCDA7DE426D04EE231") to set this as a debug device.

    iOS:
    B74F6468-1516-467C-99AD-CC5973C5DB52 in To enable debug mode for this device, set: UMPDebugSettings.testDeviceIdentifiers = @[B74F6468-1516-467C-99AD-CC5973C5DB52]

  3. Copy the device ID.
  4. Add AdizGDPRManager.setTestDevice(DEVICE_ID) before executing Adiz.initialize in the existing Hive Adiz initialization code.
  5. Create a GDPR consent message and reinitialize Hive Adiz to ensure the GDPR consent popup appears correctly.
Unity

Hive Adiz Initialization

The initialization of Hive Adiz is the essential step before exposing any type of advertisement. Initializing Hive Adiz allows you to receive the ad keys necessary for displaying ads. If test mode is enabled, you will receive a test key. If you are using the Hive SDK, proceed with the Adiz initialization after calling AuthV4.setup.

  

The JSON file received as a callback during initialization contains a list of ad keys. The format of the ad key list is as follows:

 

When initializing in test mode, you will receive a list of test ad keys even if you haven’t registered the AdMob ad key in the Hive console. When initializing in commercial mode, you will receive a list of AdMob ad keys registered in the Hive console.

For each ad type (form), one ad is used as the default ad (ad where "is_default":true). When you first register any ad type, the first registered ad becomes the default ad. You do not need to enter the ad key (hiveAdKey) when creating an ad instance (initialize()) for the default ad. To change the default ad, you must delete the existing default ad in the Hive console and register a new ad.

Ad Callback Listener Configuration

By implementing AdizListener when creating each ad instance, you can receive callbacks according to the state changes of the advertisement.

Name Description Required
.OnAdLoad(OnAdLoadCB) Ad load success O
.OnAdFail(OnAdLoadFailedCB) Failure (You can know the reason for failure through error.errorCode() and error.errorMessage()) O
.OnAdShow(OnAdShowCB) Ad exposure success O
.OnAdClick(OnAdClickCB) Ad click O
.OnAdPaidEvent(OnAdPaidEventCB) The moment of receiving a paid event after ad exposure, where ad revenue information is delivered O
.OnAdClose(OnAdCloseCB) Ad closed

  • After the ad is closed, to re-expose the same ad instance, you must call load() again and then show().
  • If you no longer wish to expose the ad, call destroy() to remove the ad instance.
X
.OnAdReward(OnAdRewardCB) The moment a user receives a reward after ad exposure in rewarded ads (rewarded, rewarded interstitial) X

Error Codes

The AdizError error codes and messages received from Adiz.Initialize and AdizListener for OnAdFail() are as follows:

Common Codes

Number Case Explanation
0 Success Success

Adiz Error Codes

Number Case Explanation
-1 InvalidParam Invalid parameter
-2 NotSupported Not supported
-3 InProgress Process in progress
-4 Network Network error
-5 NeedInitialize Initialization needed
-6 ResponseFail Response failure
-7 Timeout Network timeout
-99 Unknown Unknown error

Ad Platform Error Codes

Number Case Explanation
-101 NeedLoad Ad not loaded
-102 NeedReload Need to reload due to ad exposure time expiration
-103 NotEnoughInventory Mediation response was successful, but no filled ads due to insufficient inventory
-104 MissingAppId AppID error for mediation request
-105 InternalNetworkError Error related to mediation network
-106 InvalidUnitId Invalid Unit Id
-107 MediationNoFill Mediation adapter could not process ad request
-108 AlreadyLoaded Already in a loaded state
-109 CannotRequestAds Cannot request ads
-201 GdprConsentError GDPR consent error
-202 IsNotPrivacyOptionsRequired No need to display or unable to display the GDPR consent popup

Ad Display and Termination

To display and terminate ads, follow these steps:

  1. Create ad instances from the ad class for each ad type you want to display. If the ad you want to display is not the default ad, you must enter the ad key obtained from initialization. If you do not enter the ad key (hiveAdKey), a default ad instance is created.
  2. Load (load()) the ad you want to display.
  3. Display (show()) the loaded ad. To re-display the ad, you must call load() again and then show().
  4. To terminate the ad, call destroy().

Interstitial Ads

Full-screen ads that occupy the entire screen.

Banner Ads (Banner)

Banner ads display banners of specific sizes. Banner ads do not receive the OnAdClose() callback. Therefore, you must call destroy() from another location to terminate the ad.

 

BannerSize follows standard banner sizes.

Size Points (Width x Height) Description Supported Devices BannerSize Constant
320×50 Banner Phone and Tablet BannerSize.NORMAL
320×100 Large Banner Phone and Tablet BannerSize.MEDIUM
300×250 IAB Medium Rectangle Phone and Tablet BannerSize.LARGE
468×60 IAB Full-Size Banner Tablet BannerSize.FULL

 

PositionType is either top or bottom. The default is bottom.

Alignment Description PositionType Constant
Top Alignment Specifies alignment at the top of the screen (For iOS, specifies top alignment based on SafeArea) PositionType.TOP
Bottom Alignment (Default) Specifies alignment at the bottom of the screen (For iOS, specifies bottom alignment based on SafeArea) PositionType.BOTTOM

Native Ads (Native)

The native ads display native templates of specific sizes. Native ads are optimized for vertical screens, so it is recommended to use them in portrait mode games (vertical screen games). Native ads do not receive the OnAdClose() callback. Therefore, you must call destroy() at a different location to terminate the ad.

 

Currently, the template supports small or medium sizes.

Size Points (Width x Height) Template Alignment BannerSize Constants
355×91 (Aspect Ratio Adjusted) small size Top / Bottom BannerSize.NORMAL
355×370 (Aspect Ratio Adjusted) medium size Center (Fixed) BannerSize.MEDIUM,
BannerSize.LARGE,
BannerSize.FULL

 

In the small template, the PositionType is either top or bottom, with the default being bottom.

Alignment Description PositionType Constants
Top Alignment Specifies alignment to the top of the screen (iOS is aligned to the top of SafeArea) PositionType.TOP
Bottom Alignment (Default) Specifies alignment to the bottom of the screen (iOS is aligned to the bottom of SafeArea) PositionType.BOTTOM

 

The medium template does not allow for alignment selection and is centrally aligned by default.

 

Rewarded Ads (Rewarded)

The rewarded ads are the ads where users receive rewards for watching the ad for a certain period. Once the reward is distributed, you receive the reward item information through the OnAdReward() callback.

Rewarded Interstitial Ads (Rewarded Interstitial)

The rewarded interstitial ads are the interstitial ads where users receive rewards for watching the ad for a certain period. Once the reward is distributed, you receive the reward item information through the OnAdReward() callback.

App Opening Ads (AppOpen)

The app opening ads are displayed when the app’s state changes from background to foreground using the pre-loaded (load()) ads. If you call show() after 3 hours of ad loading, the ad is reloaded automatically before being displayed. Once the ad has been shown at least once, it will not automatically load again.

Uninstallation

To uninstall HiveAdiz, remove the following folders from your Unity project:

  • Assets/HiveAdiz
  • Assets/HiveAdiz_Example