Integration
Execute the following command to integrate the plugin:
cordova plugin add @azerion/cordova-ads
AdMob configuration
Android
Add the AdMob APPLICATION_ID
into /platforms/android/app/src/AndroidManifest.xml
<application>
...
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy" />
...
</application>
iOS
Update your app's Info.plist
file to add a GADApplicationIdentifier
key with a string value of your AdMob app ID.
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-XXXXXXXXXXXXXXXX~YYYYYYYYYY</string>
Initialize Azerion Ads SDK
azerionAds.initialise(gdprConsentString, isCOPPACompliant, withUserConsent, isTestModeEnabled, isDebugModeEnabled);
azerionAds.on('InitializationCompleted', (initializationStatus) => {
console.log(initializationStatus);
});
Sample initializationStatus
response:
{
"com.google.android.gms.ads.MobileAds": {
"description": "",
"name": "com.google.android.gms.ads.MobileAds",
"state": "READY"
},
"ImproveDigital": {
"description": "",
"name": "ImproveDigital",
"state": "READY"
}
}
NOTE
You can only request Ad after SDK successfully finished initialization. In production build isTestModeEnabled
and isDebugModeEnabled
should be false
.
Banner Ad
azerionAds.requestBanner("azerionAdUnitId", AzerionAds.AdBannerPosition.BOTTOM, AzerionAds.AdBannerSize.BANNER);
azerionAds.showBanner();
azerionAds.hideBanner();
azerionAds.on('BannerOnReceiveAd', () => {
});
azerionAds.on('BannerOnFailedToReceiveAd', (error) => {
});
azerionAds.on('BannerOnDisplay', () => {
});
azerionAds.on('BannerOnHide', () => {
});
azerionAds.on('BannerOnLeftApplication', () => {
});
Interstitial Ad
azerionAds.requestInterstitial("adUnitId");
azerionAds.on('InterstitialOnAdLoaded', () => {
azerionAds.showInterstitial();
});
azerionAds.on('InterstitialOnAdFailedToLoad', (error) => {
azerionAds.requestInterstitial("adUnitId");
});
azerionAds.on('InterstitialOnAdDisplayed', () => {
});
azerionAds.on('InterstitialOnAdFailedToDisplay', (error) => {
azerionAds.requestInterstitial("adUnitId");
});
azerionAds.on('InterstitialOnAdClosed', () => {
azerionAds.requestInterstitial("adUnitId");
});
azerionAds.on('InterstitialOnAdLeavingApplication', () => {
});
Rewarded Ad
azerionAds.requestRewardVideo("azerionAdUnitId");
azerionAds.on('RewadedVideoOnAdLoaded', () => {
azerionAds.showRewardVideo();
});
azerionAds.on('RewadedVideoOnAdFailedToLoad', (error) => {
azerionAds.requestRewardVideo("azerionAdUnitId");
});
azerionAds.on('RewadedVideoOnAdDisplayed', () => {
});
azerionAds.on('RewadedVideoOnAdFailedToDisplay', (error) => {
azerionAds.requestRewardVideo("azerionAdUnitId");
});
azerionAds.on('RewadedVideoOnAdClosed', () => {
azerionAds.requestRewardVideo("azerionAdUnitId");
});
azerionAds.on('RewadedVideoOnAdLeavingApplication', () => {
});
azerionAds.on('RewadedVideoOnUserRewardEarned', (rewardItem) => {
console.log("rewarde amount: " + rewardItem.amount);
});
-
Kotlin module issue
More than one file was found with OS independent path 'META-INF/annotation-experimental_release.kotlin_module'
Please add the following config into .../platforms/android/app/build.gradle
android {
...
packagingOptions {
exclude("META-INF/*.kotlin_module")
}
...
}
-
If you are using firebase-analytics
please update it version to 21.0.0