Meteor: Including Admob Interstitial Ads In Meteor App
I've been working on implementing Admob ads in my Meteor application with the help of the following question: Admob Question Is there a way to implement interstitial ads for an eve
Solution 1:
The way should be similar than what is exposed here: https://github.com/appfeel/admob-google-cordova/wiki/requestInterstitialAd
admob.requestInterstitialAd({publisherId:"ca-app-pub-XXXXXXXXXXXXXXXX/BBBBBBBBBB",interstitialAdId:"ca-app-pub-XXXXXXXXXXXXXXXX/IIIIIIIIII",tappxIdiOs:"/XXXXXXXXX/Pub-XXXX-iOS-IIII",tappxIdAndroid:"/XXXXXXXXX/Pub-XXXX-Android-AAAA",tappxShare:0.5,adSize:admob.AD_SIZE.SMART_BANNER,bannerAtTop:false,overlap:false,offsetStatusBar:false,isTesting:false,adExtras : {},autoShowBanner:true,autoShowInterstitial:true},success,fail);
If it is about interstitials, just to ensure it is shown at the moment you want, you can call it with autoShowIntesrtitial: false
and then implement the event listener:
var isInterstitialAvailable = false;
// Launch your appif (Meteor.isCordova && window.admob) {
document.addEventListener('deviceready', function () {
myAppRequestInterstitial();
});
}
// Request interstitial, when your app is launched and after an interstitial has been shown to request the next onefunctionmyAppRequestInterstitial() {
admob.requestInterstitialAd({
publisherId: "ca-app-pub-XXXXXXXXXXXXXXXX/BBBBBBBBBB",
interstitialAdId: "ca-app-pub-XXXXXXXXXXXXXXXX/IIIIIIIIII",
adSize: admob.AD_SIZE.SMART_BANNER,
autoShowInterstitial: false
}, success, fail);
}
// Get noticed if there is an interstitial prepared to be showndocument.addEventListener(admob.events.onAdLoaded, function (e) {
if (e.adType == admob.AD_TYPE.INTERSTITIAL) {
isInterstitialAvailable = true;
}
});
// This is the function called by your eventfunctionmyEvent() {
if (isInterstitialAvailable && isSomeOtherCondition) {
admob.showInterstitialAd(success, fail);
}
}
// Request next interstitialdocument.addEventListener(admob.events.onAdOpened, function (e) {
if (e.adType == admob.AD_TYPE.INTERSTITIAL) {
isInterstitialAvailable = false;
admob.requestInterstitialAd(options, success, fail);
}
});
You could also implement admob.events.onAdFailedToLoad
and check for error code and depending on it, setTimeout(myAppRequestInterstitial, howManyMs);
Be carefull with this user case: user leaving the app (it can cause some problems). Just ensure it works fine in all cases.
Post a Comment for "Meteor: Including Admob Interstitial Ads In Meteor App"