Hive AdKit for ADOP: C++
Hive AdKit for ADOP (hereinafter, AdKit for ADOP) is an advertisement module that uses ADOP‘s API and develops by following the guideline from ADOP. Using AdKit with Hive SDK, log data is sent to Hive Analytics server so that you can skip analyzing an advertisement.
This guide explains how to implement AdKit for ADOP with Cocos C++ so that the Hive SDK user uses ADOP under the c++ development environment. AdKit for ADOP with C++ is able to run on the iOS and Android platforms, and you can see how to set for each on this page.
Creating Development Environment
Follow the guide below for each platform to configure AdKit.
- Android
Build the Hive AdKit SourceCode embedded in SDK to use the Hive AdKit. Android Studio 4.2 and later version are recommended.- ExternalNativeBuild
Using #cmake, add the following code to the CMakeList.txt file.
1234567// 'CMakeList.txt'set(HIVEADKIT_DIR_PATH ....../HIVEAdKit) #setup to HIVEAdKit path#HIVEAdKit library import after add_library( MyGame ... )add_subdirectory(${HIVEADKIT_DIR_PATH}) #HIVEAdKit library & macro loaduse_hiveadkit_prebuilt(${HIVEADKIT_DIR_PATH} MyGame) #library import automatic macro to build target - Add the following code to the build.gradle file.
123456789apply from: '../../HIVEAdkit/adkit.gradle'android {...sourceSets.main {java.srcDirs "src" , "../../HIVEAdKit/Android/java" // HIVEAdKit JavaPlugin Source Path}...} - Add AdMobId, which is formatted in ca–app–pub–XXXXX~YYYYY, to the AndroidManifest.xml file.
123456<application><meta-data android:name="com.google.android.gms.ads.AD_MANAGER_APP" android:value="true" /><meta-dataandroid:name="com.google.android.gms.ads.APPLICATION_ID"android:value="ca-app-pub-XXXXX~YYYYY"/></application>
- ExternalNativeBuild
- iOS
Build the Hive AdKit SourceCode embedded in SDK to use the Hive AdKit.- Drag and drop the HIVEAdKit/src and HIVEAdKit/include folders to XCode project.
- Include all files with .cpp, .hpp and .mm extensions.
- Hive AdKit provides bridge-pattern code for the actual use.
- Add HIVEAdKit/include/bidmad to Project > BuildSetting > Search Paths.
- Add
GADApplicationIdentifier
to Info.plist of the Xcode project generated in Unity build, and enter AdMobId, which is formatted in ca-app-pub-XXXXX~YYYYY, as string type.
12<key>GADApplicationIdentifier</key><string>ca-app-pub-XXXXX~YYYYY</string>On iOS 14 and higher, add SKAdNetworkItems to Info.plist. - Add the following to CocoaPods settings.
1234567891011platform :ios, '11.0'target 'MyGame-mobile' douse_frameworks! :linkage => :staticpod 'BidmadSDK', '4.0.1.1'pod 'OpenBiddingHelper', '4.0.1.1'pod 'BidmadAdapterFNC/ForGame', '4.0.0.2'pod 'BidmadAdapterFC', '4.0.0.0'end - Run the following to apply CocoaPod settings.
1$pod install
- Drag and drop the HIVEAdKit/src and HIVEAdKit/include folders to XCode project.
How to Use
Test Ad Key in ADOP
Using a test ad key that ADOP issued is required.
1 2 3 4 5 6 7 8 9 10 |
#if defined(ANDROID) const char* rewardVideoId = "7d9a2c9e-5755-4022-85f1-6d4fc79e4418"; const char* InterstitialAdId = "e9acd7fc-a962-40e4-aaad-9feab1b4f821"; const char* AdaptiveBannerAdId = "944fe870-fa3a-4d1b-9cc2-38e50b2aed43"; #else// UNITY_IOS const char* rewardVideoId = "29e1ef67-98d2-47b3-9fa2-9192327dd75d"; const char* InterstitialAdId = "228b95a9-6f42-46d8-a40d-60f17f751eb1"; const char* AdaptiveBannerAdId = "1c3e3085-333f-45af-8427-2810c26a72fc"; #endif |
Initializing Hive AdKit
If your app is targetting the users in the European Economic Area (EEA) and the UK, you have to obtain GDPR consent. Go to the UserMessagingPlatform Library of Google AdMob and follow the guide to get the consent.
1 2 3 4 5 6 |
// When distributing common use HIVEAdKit::GDPR::Setup(false, nullptr); // When using GDPR test HIVEAdKit::GDPR::Reset(); HIVEAdKit::GDPR::Setup(true, testDeviceId); |
Reward ads
Rewarded ads reward a user who watched a video for a period of time, and is able to load one ad at a time.
1 2 3 4 5 6 7 8 9 10 |
// Create RewardVideoAd Instance auto rewardVideo = HIVEAdKit::RewardVideo::Initialize(rewardVideoId, this); // Load RewardVideoAd HIVEAdKit::RewardVideo::Load(*rewardVideo, "RewardVideo-Load-AdPlacementInfo"); // Show RewardVideoAd if( HIVEAdKit::RewardVideo::IsLoaded(*rewardVideo) ) { HIVEAdKit::RewardVideo::Show(*rewardVideo, "RewardVideo-Show-AdPlacementInfo"); } |
Interstitial ads
Interstitial ads are full-screen ads that cover the interface of game.
1 2 3 4 5 6 7 8 9 10 |
// Create InterstitialAd Instance auto interstitial = HIVEAdKit::Interstitial::Initialize(InterstitialAdId, this); // Load InterstitialAd HIVEAdKit::Interstitial::Load(*interstitial, "Interstitial-Load-AdPlacementInfo"); // Show InterstitialAd if( HIVEAdKit::Interstitial::IsLoaded(*interstitial) ) { HIVEAdKit::Interstitial::Show(*interstitial, "Interstitial-Show-AdPlacementInfo"); } |
Adaptive Banner ads
Adaptive Banner ads are a type of rolling banner that occupies a spot on screen. The banner’s position is adjustable with the yPos
value.
1 2 3 4 5 6 7 8 9 10 11 |
// Create AdaptiveBanner Instance auto adaptiveBanner = HIVEAdKit::AdaptiveBanner::Initialize(AdaptiveBannerAdId, this, yPos); // Load AdaptiveBanner HIVEAdKit::AdaptiveBanner::Load(*adaptiveBanner, "Banner-Load-AdPlacementInfo"); // Show AdaptiveBanner HIVEAdKit::AdaptiveBanner::Show(*adaptiveBanner, "Banner-Show-AdPlacementInfo"); // Hide AdaptiveBanner HIVEAdKit::AdaptiveBanner::Hide(*adaptiveBanner); |
Test Ads
It is important for advertiser not to be charged when test ad is clicked in development. If you click ads too much out of test mode, it is regarded as invalid action. Therefore, be aware not to be a target account to report. Refer to the Google Developers to use a test ad.