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 caapppubXXXXX~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 caapppubXXXXX~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

Hive Adiz Initialization

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

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