Hive Adkit for AD(X): C++
Creating Development Environment
- Android
Build the Prebuilt–Firebase–Library and embedded Hive AdKit SourceCode to use the Hive AdKit. Android Studio 3.0 and later version are recommended.- ExternalNativeBuild
- [Case 1] Using #ndk–build
1234// ‘Android.mk’$(call import-add-path,$(LOCAL_PATH)/../../..) #Path setup to install HIVEAdKit module$(call import-module, HIVEAdKit) #Load the configuration of HIVEAdKit module$(call import-module, HIVEAdKit/firebase_cpp_sdk) #Load the prebuilt version of firebase_cpp_sdk module to use HIVEAdKit - [Case 2] Using #cmake
1234567// 'CMakeList.txt'set(HIVEADKIT_DIR_PATH ....../HIVEAdKit) #Path setup to install HIVEAdKit module#Import HIVEAdKit library after add_library (MyGame ...)add_subdirectory(${HIVEADKIT_DIR_PATH}) #HIVEAdKit library & macro loaduse_hiveadkit_prebuilt(${HIVEADKIT_DIR_PATH} MyGame) #Import the library import automatic macro to build target
- [Case 1] Using #ndk–build
- Add the followings to the build.gradle file.
1234567891011121314android {...sourceSets.main {java.srcDirs "src" , "../../HIVEAdKit/Android/java" // HIVEAdKit JavaPlugin Source Path}...}gradle.ext.firebase_cpp_sdk_dir = "../HIVEAdKit/firebase_cpp_sdk" // setup HIVEAdKit/firebase_cpp_sdk Pathapply from: "$gradle.firebase_cpp_sdk_dir/Android/firebase_dependencies.gradle"firebaseCpp.dependencies {admob}
- In case of using AD(X) or ADOP with AdMob–AdManager Service, add the followings 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-3940256099942544~3347511713"/> <!-- Sample value --></application>
- In case of using AD(X), add the followings to the build.gradle file.
1234567android {...dependencies {...implementation "com.github.adxcorp.ADXLibrary_Android:adx-library-rewarded-video:1.16.2"}}
- ExternalNativeBuild
- iOS
Build the Firebase-Framework and the included AdKit source code to use this feature.- 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/firebase_cpp_sdk/frameworks/ios/universal to Project > Build Settings > Search Paths > Framework Search Path.
- Add HIVEAdKit/firebase_cpp_sdk/include to Project > Build Settings > Search Paths > Header Search Path.
- Add -framework “firebase” and -framework “firebase_admob” to Project > Build Settings > Other Flags.
- Add the following to CocoaPods settings.
1$pod ‘Firebase/AdMob’ - In case of using AD(X), add the followings to CocoaPods settings.
12$source 'https://github.com/adxcorp/AdxLibrary_iOS_Release.git'$pod 'ADXLibrary' - In order to download the latest SDK of iOS from Xcode, you need to execute the following command.
1pod install --repo-update
- Drag and drop the HIVEAdKit/src and HIVEAdKit/include folders to XCode project.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#if defined(ANDROID) const char* appId = "ca-app-pub-3940256099942544~3347511713"; const char* rewardVideoUnitId = "ca-app-pub-3940256099942544/5224354917"; const char* InterstitialAdUnitId = "ca-app-pub-3940256099942544/1033173712"; const char* AdaptiveBannerAdUnitId = "ca-app-pub-3940256099942544/6300978111"; #else // iOS const char* appId = "ca-app-pub-3940256099942544~1458002511"; const char* rewardVideoUnitId = "ca-app-pub-3940256099942544/1712485313"; const char* InterstitialAdUnitId = "ca-app-pub-3940256099942544/4411468910"; const char* AdaptiveBannerAdUnitId = "ca-app-pub-3940256099942544/2934735716"; #endif |
Features
If you use Reward Video API from Hive AdKit C++ with Hive SDK, sending log data depends on the implemented RewardVideo API. Log data is sent to Hive Analytics server, and this feature is available with the following version and later of Hive SDK. It doesn’t work if Hive SDK is not initialized or existed.
- Hive SDK v4.11.0
How to use Hive AdKit is as follows.
Initializing AdMob
Required step before initializing, loading and showing all types of advertisement (AD)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
//App ID, API key, and Project ID must be specified in App options. firebase::AppOptions appOptions = firebase::AppOptions(); #ifdef __ANDROID__ // Android Only appOptions.set_app_id("331526026701"); appOptions.set_api_key("AIzaSyAxOUz9NQtpZZD_XvfD5L7V1dZZ96tYwZ8");// appOptions.set_project_id("core-cocos-test"); #endif firebase::InitResult result = HIVEAdKit::AdMobInitialize(appOptions); if(result == firebase::kInitResultSuccess) { // AdMob initialization successful } |
Rewarded type
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 |
// Initialize auto rewardVideo = HIVEAdKit::RewardVideo::Initialize(rewardVideoUnitId, this, getAdMobViewParent(), [=](const firebase::Future< void >& completed_future) { if (completed_future.error() == 0) { // Initiallized successfully } }); // Load // Send AD loading information to Hive Analytics std::string adPlacement = "CocosCPP-RewardVideo-Load-AdditionalInfo"; firebase::admob::AdRequest my_ad_request = {}; HIVEAdKit::RewardVideo::Load(*rewardVideo, my_ad_request, adPlacement, [=](const firebase::Future< void >& completed_future) { if (completed_future.error() == 0) { // Loaded successfully } }); // Show // Send AD loading information to Hive Analytics std::string adPlacement = "CocosCPP-RewardVideo-Show-AdditionalInfo"; HIVEAdKit::RewardVideo::Show(*rewardVideo, adPlacement, [=](const firebase::Future< void >& completed_future) { if (completed_future.error() == 0) { // Shown successfully } }); |
Interstitial type
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 |
// Initialize auto interstitial = HIVEAdKit::Interstitial::Initialize(InterstitialAdUnitId, this, getAdMobViewParent(), [=](const firebase::Future< void >& completed_future) { if (completed_future.error() == 0) { // Initiallized successfully } }); // Load // Send AD loading information to Hive Analytics std::string adPlacement = "CocosCPP-Interstitial-Load-AdditionalInfo"; firebase::admob::AdRequest my_ad_request = {}; HIVEAdKit::Interstitial::Load(*interstitial, my_ad_request, adPlacement, [=](const firebase::Future< void >& completed_future) { if (completed_future.error() == 0) { // Loaded successfully } }); // Show // Send AD loading information to Hive Analytics std::string adPlacement = "CocosCPP-Interstitial-Show-AdditionalInfo"; HIVEAdKit::Interstitial::Show(*interstitial, adPlacement, [=](const firebase::Future< void >& completed_future) { if (completed_future.error() == 0) { // Shown successfully } }); |
Adaptive Banner type
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 |
// Initialize auto adaptiveBanner = HIVEAdKit::AdaptiveBanner::Initialize(AdaptiveBannerAdUnitId, this, getAdMobViewParent(), banner_ad_size, bannerPosition, [=](const firebase::Future< void >& completed_future) { if (completed_future.error() == 0) { // Initialized successfully } }); // Set banner position HIVEAdKit::AdaptiveBanner::SetPosition(*adaptiveBanner, bannerPosition, [=](const firebase::Future< void >& completed_future) { }); // Load // Send AD loading information to Hive Analytics std::string adPlacement = "CocosCPP-AdaptiveBanner-Load-AdditionalInfo"; firebase::admob::AdRequest my_ad_request = {}; HIVEAdKit::AdaptiveBanner::Load(*adaptiveBanner, my_ad_request, adPlacement, [=](const firebase::Future< void >& completed_future) { if (completed_future.error() == 0) { // Loaded successfully } }); // Show // Send AD loading information to Hive Analytics std::string adPlacement = "CocosCPP-AdaptiveBanner-Show-AdditionalInfo"; HIVEAdKit::AdaptiveBanner::Show(*adaptiveBanner, adPlacement, [=](const firebase::Future< void >& completed_future) { if (completed_future.error() == 0) { // Shown successfully } }); // Hide HIVEAdKit::AdaptiveBanner::Hide(*adaptiveBanner, [=](const firebase::Future< void >& completed_future) { if (completed_future.error() == 0) { // Hidden successfully } }); |
Supporting iOS 14
Following is SKAdNetwork list of AD(X) for supporting iOS 14 and later version. AdKitPostprocess is based on the update on January 29, 2021. Don’t forget to check the latest update.
- SKAdNetwork update
Unity Integrate Notice
- Follow the procedures below to sync the ADXUnityPackage 1.10.0 or higher under the Unity Engine 2019.4 or higher envorinment.
- In the Unity editor, check Assets > External Dependency Manager > iOS Resolver > Settings > Add use_frameworks! to Podfile and Link frameworks statically, then save it.
- Add OMSDK_Mopub.xcframework (Pods/mopub–ios–sdk/Frameworks/OMSDK_Mopub.xcframework) on iOS PROJECT > Targets > Build Phases > Embed Frameworks.
- Add FBSDKCoreKit_Basics.xcframework (Pods/FBSDKCoreKit_Basics/XCFrameworks/FBSDKCoreKit_Basics.xcframework) on Targets > Build Phases > Embed Frameworks to sync the ADXUnityPackage 1.10.3 or higher under the Unity Engine 2019.4 or higher envorinment.
- In the Unity editor, check Assets > External Dependency Manager > iOS Resolver > Settings > Add use_frameworks! to Podfile and Link frameworks statically, then save it.
- If the App ID on GoogleMobileAdsSettings is removed, go to Unity > Assets > Google Mobile Ads > Settings and select the Delay app measurement checkbox, then clear it again.
Issue Check
If you develop your game with Cocos2D-X, some of FlatBuffers libraries in Cocos2D-X engine and Firebase-embedded libraries are duplicated. To prevent the duplication, try not to include the FlatBuffers libraries or directly build the open-source libraries provided by Firebase. Firebase includes the below libraries. If the libraries crash due to duplication, use Firebase open-source libraries for building your project manually.
- Curl
- FlatBuffers
- libuv
- Nanopb
- uWebSockets
- Zlib