方法应与此处公开的类似:
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);
如果它是关于空格的,为了确保它在你想要的时候显示,你可以用
autoShowIntesrtitial: false
然后实现事件监听器:
var isInterstitialAvailable = false;
// Launch your app
if (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 one
function myAppRequestInterstitial() {
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 shown
document.addEventListener(admob.events.onAdLoaded, function (e) {
if (e.adType == admob.AD_TYPE.INTERSTITIAL) {
isInterstitialAvailable = true;
}
});
// This is the function called by your event
function myEvent() {
if (isInterstitialAvailable && isSomeOtherCondition) {
admob.showInterstitialAd(success, fail);
}
}
// Request next interstitial
document.addEventListener(admob.events.onAdOpened, function (e) {
if (e.adType == admob.AD_TYPE.INTERSTITIAL) {
isInterstitialAvailable = false;
admob.requestInterstitialAd(options, success, fail);
}
});
您还可以实施
admob.events.onAdFailedToLoad
并检查错误代码,
setTimeout(myAppRequestInterstitial, howManyMs);
小心这个用户案例:用户离开应用程序(这可能会导致一些问题)。只要确保它在所有情况下都能正常工作。