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
- Download the latest version of Hive Adiz here and unzip it.
- In Unity, go to Assets > Import Package > Custom Package…, select the .unitypackage file, and click Import.
- Check if Hive Adiz 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, 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.
1 2 3 4 5 6 7 8 |
<manifest> <application> <!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 --> <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/> </application> </manifest> |
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.
1 2 3 4 5 6 |
<application android:hardwareAccelerated="true"> <!-- For activities that use ads, hardwareAcceleration should be true. --> <activity android:hardwareAccelerated="true" /> </application> |
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.
1 2 3 |
-keep class com.hive.** { *; } |
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:
- Use the Custom Base Gradle Template.
- Check Build Settings > Project Settings > Player > Custom Base Gradle Template.
- Assets/Plugins/Android/baseProjectTemplate.gradle will be created.
- 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
.
- Open the file Assets/Plugins/Android/baseProjectTemplate.gradle and change the version like
- Download the required version of Gradle, then unzip it in your desired path.
- Change the Gradle installation path in Unity.
- Uncheck Preferences > External Tools > Gradle Installed with Unity.
- Set the path where you unzipped Gradle.
- 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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
source 'https://github.com/CocoaPods/Specs.git' source 'https://github.com/Com2uSPlatformCorp/HiveAdiz-iOS.git' platform :ios, '12.0' target 'UnityFramework' do pod 'HiveAdizUnityPlugin', '1.1.0' end target 'Unity-iPhone' do end use_frameworks! # fix for dyld issue in pods when using Project post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| # xcode 15 Toolchain Issue xcconfig_path = config.base_configuration_reference.real_path xcconfig = File.read(xcconfig_path) xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR") File.open(xcconfig_path, "w") { |file| file << xcconfig_mod } # end config.build_settings["BUILD_LIBRARY_FOR_DISTRIBUTION"] = "YES" if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 12.0 config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0' end end end end |
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.
1 2 3 4 |
<key>GADApplicationIdentifier</key> <string>ca-app-pub-XXXXX~YYYYY</string> |
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.
1 2 3 4 5 6 7 8 9 |
using hiveAdiz; // Enable test mode. Comment out the below line when distributing commercially. Adiz.SetTestMode(true); // Enable logging for the Hive Adiz module. Logging should only be used in test mode. Comment out the below line when distributing commercially. Adiz.SetLogEnable(true); |
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.
1 2 3 |
Adiz.SetAppId(appId); |
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
1 2 3 4 |
ZoneType selectZone = ZoneType.REAL; Adiz.SetZone((int)selectZone); |
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.
- Guide to Applying IDFA
- Guide to Creating IDFA Message
- Explanation of IDFA Messages and ATT Notifications
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:
- Implement a button UI in your app to reload the GDPR consent popup window.
- 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, callshowPrivacyOptionsForm
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. TheshowPrivacyOptionsForm
method provided below is for illustration purposes only and can be implemented in any form desired by the developer.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
using hiveAdiz; public void Initialize() { // ... 생략 // Hive Adiz 초기화 Adiz.Initialize(new CommonHandlers.Builder() .OnResult(InitResultCB) .Build()); } private void InitResultCB(AdizError error, string jsonString) { // 초기화 완료 콜백 함수 Debug.Log(TAG + "::InitResultCB:: errorCode : "+error.errorCode+" errorMessage : "+error.errorMessage+" json : "+jsonString); if(error.isSuccess()) { bool isPrivacyOptionsRequired = AdizGDPRManager.IsPrivacyOptionsRequired(); if(isPrivacyOptionsRequired) { // 개인 정보 보호 옵션 버튼 show. 클릭시 ShowPrivacyOptionsForm call } else { // 개인 정보 보호 옵션 버튼 hide } } } private void ShowPrivacyOptionsForm() { // 개인 정보 보호 옵션 양식 호출 if(AdizGDPRManager.IsPrivacyOptionsRequired()) { AdizGDPRManager.ShowPrivacyOptionsForm(new CommonHandlers.Builder() .OnResult(CommonResultCB) .Build()); } } private void CommonResultCB(AdizError error, string jsonString) { // 개인 정보 보호 옵션 양식 호출 완료 콜백. 별도의 에러 처리가 필요하지 않음 Debug.Log(TAG + "::CommonResultCB:: errorCode : "+error.errorCode+" errorMessage : "+error.errorMessage); } |
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:
- 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.
-
Print Android Studio log or Xcode log to get the device ID. The following log is an example.
Android:
33BE2250B43518CCDA7DE426D04EE231
inUse new ConsentDebugSettings.Builder().addTestDeviceHashedId("33BE2250B43518CCDA7DE426D04EE231") to set this as a debug device.
iOS:
B74F6468-1516-467C-99AD-CC5973C5DB52
inTo enable debug mode for this device, set: UMPDebugSettings.testDeviceIdentifiers = @[B74F6468-1516-467C-99AD-CC5973C5DB52] - Copy the device ID.
- Add
AdizGDPRManager.setTestDevice(DEVICE_ID)
before executingAdiz.initialize
in the existing Hive Adiz initialization code. - Create a GDPR consent message and reinitialize Hive Adiz to ensure the GDPR consent popup appears correctly.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
using hiveAdiz; public void Initialize() { // Setting up GDPR Test Devices AdizGDPRManager.SetTestDevice("33BE2250B43518CCDA7DE426D04EE231"); Adiz.Initialize(new CommonHandlers.Builder() .OnResult(InitResultCB) .Build()); } |
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
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
using hiveAdiz; public void Start() { /* omitted */ // To use HiveAdiz callbacks, you need to register AdizCallbackManager as a GameObject. Adiz.InitPlugin(); } Adiz.Initialize(new CommonHandlers.Builder() .OnResult(InitResultCB) .Build()); // Initialize Callback listener private void InitResultCB(AdizError error, string jsonString) { Debug.Log(TAG + "::InitResultCB:: errorCode : "+error.errorCode+" errorMessage : "+error.errorMessage+" json : "+jsonString); if(error.isSuccess()) { JSONObject resJsonObject = new JSONObject (jsonString); JSONObject jsonArray = resJsonObject.GetField ("keys"); if (jsonArray != null && jsonArray.count > 0) { List<string> interstitialKeyList = new List<string>(); List<string> bannerKeyList = new List<string>(); List<string> nativeKeyList = new List<string>(); List<string> rewardedKeyList = new List<string>(); List<string> rewardedInterstitialKeyList = new List<string>(); List<string> appOpenKeyList = new List<string>(); List<JSONObject> jsonList = jsonArray.list; foreach (JSONObject jsonItem in jsonList) { bool isDefault = false; jsonItem.GetField(ref isDefault, "is_default"); // This is an example of constructing a list of keys where is_default is false, in case you want to enter the ad keys directly in the game. if(isDefault) { string hiveAdKey = null; jsonItem.GetField(ref hiveAdKey, "key"); string form = null; jsonItem.GetField(ref form, "form"); switch (form) { case "interstitial": interstitialKeyList.Add(hiveAdKey); break; case "banner": bannerKeyList.Add(hiveAdKey); break; case "native": nativeKeyList.Add(hiveAdKey); break; case "rewarded": rewardedKeyList.Add(hiveAdKey); break; case "rewarded_interstitial": rewardedInterstitialKeyList.Add(hiveAdKey); break; case "app_open": appOpenKeyList.Add(hiveAdKey); break; } } } foreach(string hiveAdKey in interstitialKeyList) { Debug.Log("onSdkInitialize interstitialKeyList "+hiveAdKey); } foreach(string hiveAdKey in bannerKeyList) { Debug.Log("onSdkInitialize bannerKeyList "+hiveAdKey); } foreach(string hiveAdKey in nativeKeyList) { Debug.Log("onSdkInitialize nativeKeyList "+hiveAdKey); } foreach(string hiveAdKey in rewardedKeyList) { Debug.Log("onSdkInitialize rewardedKeyList "+hiveAdKey); } foreach(string hiveAdKey in rewardedInterstitialKeyList) { Debug.Log("onSdkInitialize rewardedInterstitialKeyList "+hiveAdKey); } foreach(string hiveAdKey in appOpenKeyList) { Debug.Log("onSdkInitialize appOpenKeyList "+hiveAdKey); } } } } |
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
{ "keys":[ { "mediation_id":5, "key":"ca-app-pub-3940256099942544/5354046379", "form":"rewarded_interstitial", "is_default":true }, { "mediation_id":4, "key":"ca-app-pub-3940256099942544/5224354917", "form":"rewarded", "is_default":true }, { "mediation_id":3, "key":"ca-app-pub-3940256099942544/2247696110", "form":"native", "is_default":true }, { "mediation_id":1, "key":"ca-app-pub-3940256099942544/1033173712", "form":"interstitial", "is_default":true }, { "mediation_id":2, "key":"ca-app-pub-3940256099942544/6300978111", "form":"banner", "is_default":true }, { "mediation_id":6, "key":"ca-app-pub-3940256099942544/9257395921", "form":"app_open", "is_default":true } ] } |
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
|
X |
.OnAdReward(OnAdRewardCB) | The moment a user receives a reward after ad exposure in rewarded ads (rewarded , rewarded interstitial ) |
X |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
private void OnAdLoadCB() { // Called when the ad is loaded. // If the ad load is successful, you should call .show() of the ad instance at the desired moment to display the ad. Debug.Log(TAG + "::OnAdLoadCB"); // Expose after AdizInterstitial is loaded // requestShowAd(); } private void OnAdLoadFailedCB(AdizError error) { // Called when the ad load fails or the ad exposure fails for another reason. Debug.Log(TAG + "::OnAdLoadFailedCB errorCode " + error.errorCode); Debug.Log(TAG + "::OnAdLoadFailedCB errorMessage " + error.errorMessage); } private void OnAdShowCB() { // Called when the ad is exposed. Debug.Log(TAG + "::OnAdShowCB"); } private void OnAdCloseCB() { // Called when the ad is closed. Debug.Log(TAG + "::OnAdCloseCB"); // Remove AdizInterstitial ad after exposure // requestDestroyAd(); } private void OnAdClickCB() { // Called when the ad is clicked. Debug.Log(TAG + "::OnAdClickCB"); } private void OnAdRewardCB(RewardItem rewardItem) { // Called when a reward is granted for watching an ad in rewarded or rewarded interstitial ads. Debug.Log(TAG + "::OnAdRewardCB:: rewardItem.itemType : " + rewardItem.getItemType() + " rewardItem.itemAmount : " + rewardItem.getItemAmount()); // Delivered only in rewarded, rewardedInterstitial ads } private void OnAdPaidEventCB(AdRevenueData adRevenueData) { // Called when revenue is generated for the ad. Debug.Log(TAG + "::OnAdPaidEventCB:: adRevenueData.revenue : " + adRevenueData.getRevenue() + " adRevenueData.currency : " + adRevenueData.getCurrency()); } |
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:
- 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. - Load (
load()
) the ad you want to display. - Display (
show()
) the loaded ad. To re-display the ad, you must callload()
again and thenshow()
. - To terminate the ad, call
destroy()
.
Interstitial Ads
Full-screen ads that occupy the entire screen.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
// Create AdizInterstitial Instance private AdizInterstitial InterstitialAd = null; public void requestInitAd(string interstitialAdKey) { AdEventHandlers eventHandlers = new AdEventHandlers.Builder() .OnAdLoad(OnAdLoadCB) .OnAdShow(OnAdShowCB) .OnAdClose(OnAdCloseCB) .OnAdClick(OnAdClickCB) .OnAdFail(OnAdLoadFailedCB) .OnAdPaidEvent(OnAdPaidEventCB) .Build(); if(string.IsNullOrEmpty(interstitialAdKey)) { // Initialize Default AdizInterstitial Instance (AdEventHandlers) InterstitialAd = AdizInterstitial.Initialize(eventHandlers); } else { // Initialize AdizInterstitial Instance (hiveAdKey, AdEventHandlers) InterstitialAd = AdizInterstitial.Initialize(interstitialAdKey, eventHandlers); } } public void requestLoadAd() { // Load AdizInterstitial if(InterstitialAd != null) InterstitialAd.Load(); } public void requestShowAd() { // Show AdizInterstitial if(InterstitialAd != null) InterstitialAd.Show(); } public void requestDestroyAd() { // Destroy AdizInterstitial if(InterstitialAd != null) InterstitialAd.Destroy(); InterstitialAd = null; } |
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 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
// Create AdizBanner Instance private AdizBanner BannerAd = null; public void requestInitAd(string bannerAdKey) { // Set banner size private BannerSize bannerSize = BannerSize.NORMAL; AdEventHandlers eventHandlers = new AdEventHandlers.Builder() .OnAdLoad(OnAdLoadCB) .OnAdShow(OnAdShowCB) .OnAdClose(OnAdCloseCB) .OnAdClick(OnAdClickCB) .OnAdFail(OnAdLoadFailedCB) .OnAdPaidEvent(OnAdPaidEventCB) .Build(); if(string.IsNullOrEmpty(bannerAdKey)) { // Initialize Default AdizBanner Instance (AdEventHandlers) BannerAd = AdizBanner.Initialize(bannerSize, eventHandlers); } else { // Initialize AdizBanner Instance (hiveAdKey, AdEventHandlers) BannerAd = AdizBanner.Initialize(bannerAdKey, bannerSize, eventHandlers); } } public void requestLoadAd() { // Load AdizBanner if(BannerAd != null) BannerAd.Load(); } public void requestShowAd() { // Set position type private PositionType bannerPosition = PositionType.TOP; // Show AdizBanner if(BannerAd != null) BannerAd.Show(bannerPosition); } public void requestDestroyAd() { // Destroy AdizBanner if(BannerAd != null) BannerAd.Destroy(); BannerAd = null; } |
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
// Create AdizNative Instance private AdizNative NativeAd = null; public void requestInitAd(string nativeAdKey) { // Set banner size private BannerSize bannerSize = BannerSize.NORMAL; AdEventHandlers eventHandlers = new AdEventHandlers.Builder() .OnAdLoad(OnAdLoadCB) .OnAdShow(OnAdShowCB) .OnAdClose(OnAdCloseCB) .OnAdClick(OnAdClickCB) .OnAdFail(OnAdLoadFailedCB) .OnAdPaidEvent(OnAdPaidEventCB) .Build(); if(string.IsNullOrEmpty(nativeAdKey)) { // Initialize Default AdizNative Instance (AdEventHandlers) NativeAd = AdizNative.Initialize(bannerSize, eventHandlers); } else { // Initialize AdizNative Instance (hiveAdKey, AdEventHandlers) NativeAd = AdizNative.Initialize(nativeAdKey, bannerSize, eventHandlers); } } public void requestLoadAd() { // Load AdizNative if(NativeAd != null) NativeAd.Load(); } public void requestShowAd() { // Set position type private PositionType bannerPosition = PositionType.TOP; // Show AdizNative if(NativeAd != null) NativeAd.Show(bannerPosition); } public void requestDestroyAd() { // Destroy AdizNative if(NativeAd != null) NativeAd.Destroy(); NativeAd = null; } |
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
// Create AdizRewarded Instance private AdizRewarded RewardVideoAd = null; public void requestInitAd(string rewardedAdKey) { AdEventHandlers eventHandlers = new AdEventHandlers.Builder() .OnAdLoad(OnAdLoadCB) .OnAdShow(OnAdShowCB) .OnAdClose(OnAdCloseCB) .OnAdClick(OnAdClickCB) .OnAdFail(OnAdLoadFailedCB) .OnAdReward(OnAdRewardCB) .OnAdPaidEvent(OnAdPaidEventCB) .Build(); if(string.IsNullOrEmpty(rewardedAdKey)) { // Initialize Default AdizRewarded Instance (AdEventHandlers) RewardVideoAd = AdizRewarded.Initialize(eventHandlers); } else { // Initialize AdizRewarded Instance (hiveAdKey, AdEventHandlers) RewardVideoAd = AdizRewarded.Initialize(rewardedAdKey, eventHandlers); } } public void requestLoadAd() { // Load AdizRewarded if(RewardVideoAd != null) RewardVideoAd.Load(); } public void requestShowAd() { // Show AdizRewarded if(RewardVideoAd != null) RewardVideoAd.Show(); } public void requestDestroyAd() { // Destroy AdizRewarded if(RewardVideoAd != null) RewardVideoAd.Destroy(); RewardVideoAd = null; } |
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
// Create AdizRewardedInterstitial Instance private AdizRewardedInterstitial RewardedInterstitialAd = null; public void requestInitAd(string rewardedInterstitialAdKey) { AdEventHandlers eventHandlers = new AdEventHandlers.Builder() .OnAdLoad(OnAdLoadCB) .OnAdShow(OnAdShowCB) .OnAdClose(OnAdCloseCB) .OnAdClick(OnAdClickCB) .OnAdFail(OnAdLoadFailedCB) .OnAdReward(OnAdRewardCB) .OnAdPaidEvent(OnAdPaidEventCB) .Build(); if(string.IsNullOrEmpty(rewardedInterstitialAdKey)) { // Initialize Default AdizRewardedInterstitial Instance (AdEventHandlers) RewardedInterstitialAd = AdizRewardedInterstitial.Initialize(eventHandlers); } else { // Initialize AdizRewardedInterstitial Instance (hiveAdKey, AdEventHandlers) RewardedInterstitialAd = AdizRewardedInterstitial.Initialize(rewardedInterstitialAdKey, eventHandlers); } } public void requestLoadAd() { // Load AdizRewardedInterstitial if(RewardedInterstitialAd != null) RewardedInterstitialAd.Load(); } public void requestShowAd() { // Show AdizRewardedInterstitial if(RewardedInterstitialAd != null) RewardedInterstitialAd.Show(); } public void requestDestroyAd() { // Destroy AdizRewardedInterstitial if(RewardedInterstitialAd != null) RewardedInterstitialAd.Destroy(); RewardedInterstitialAd = null; } |
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
// Create AdizAppOpen Instance private AdizAppOpen AppOpenAd = null; public void requestInitAd(string appOpenAdKey) { AdEventHandlers eventHandlers = new AdEventHandlers.Builder() .OnAdLoad(OnAdLoadCB) .OnAdShow(OnAdShowCB) .OnAdClose(OnAdCloseCB) .OnAdFail(OnAdLoadFailedCB) .OnAdClick(OnAdClickCB) .OnAdPaidEvent(OnAdPaidEventCB) .Build(); if(string.IsNullOrEmpty(appOpenAdKey)) { // Initialize Default AdizAppOpen Instance (AdEventHandlers) AppOpenAd = AdizAppOpen.Initialize(eventHandlers); } else { // Initialize AdizAppOpen Instance (hiveAdKey, AdEventHandlers) AppOpenAd = AdizAppOpen.Initialize(appOpenAdKey, eventHandlers); } } public void requestLoadAd() { // Load AdizAppOpen if(AppOpenAd != null) AppOpenAd.Load(); } public void requestShowAd() { // Show AdizAppOpen Debug.Log("[appOpenAd] appOpenAd don't request Show"); } public void requestDestroyAd() { // Destroy AdizAppOpen if(AppOpenAd != null) AppOpenAd.Destroy(); AppOpenAd = null; } |
Uninstallation
To uninstall HiveAdiz, remove the following folders from your Unity project:
- Assets/HiveAdiz
- Assets/HiveAdiz_Example