0
我已经使用我的Ionic App实施了cordova-admob-pro插件。如何仅在完成关卡后才显示AdMob插页式广告
我希望在完成某个级别后显示插页式广告,并在应用加载时显示而不是。
这里是我的代码:
app.js
// AdMob
if (window.plugins && window.plugins.AdMob && showAds) {
DebugService.add('admob OK');
if (window.plugins && window.plugins.AdMob) {
var admob_banner_key = device.platform == "Android" ? "ca-app-pub-7...6" : "ca-app-pub-7...0";
var admob_interstitial_key = device.platform == "Android" ? "ca-app-pub-7...5 " : "ca-app-pub-7...6";
var admob = window.plugins.AdMob;
admob.createBannerView(
{
'publisherId': admob_banner_key,
'adSize': admob.AD_SIZE.BANNER,
'bannerAtTop': false
},
function() {
admob.requestAd(
{'isTesting': true},
function() {
admob.showAd(true);
},
function() {
DebugService.add('failed to request ad');
}
);
},
function() {
DebugService.add('failed to create banner view');
}
);
admob.createInterstitialView(
{
'publisherId': admob_interstitial_key,
'autoShow': false
},
function() {
DebugService.add('interstitial successfully craeted');
},
function() {
DebugService.add('failed to add interstitial :-(');
}
);
}
}
controller.js:
if ($scope.levelId % 3 === 0) {
// after every second level and every third level after that
DebugService.add("Show interstitial ad :-)");
if ($localStorage.noAdsPurchased !== true &&
window.plugins && window.plugins.AdMob) {
DebugService.add('Ready to show interstitial');
window.plugins.AdMob.requestInterstitialAd(
{'isTesting': true},
function() {
window.plugins.AdMob.showInterstitialAd(true,
function(){
DebugService.add('interstitial successfully shown');
},
function(){
DebugService.add('interstitial show failed');
});
DebugService.add('interstitial successfully requested');
},
function() {
DebugService.add('failed to request interstitial');
}
);
DebugService.add('After showing interstitial');
}
}
的插页式广告,也显示了在启动,这是我不想要的。如果我删除了代码,或者尝试仅将app.js中的代码用于插页式广告,那么插页式广告根本不会显示。我在想,因为他们还没有开始。
如何在不开始插入广告的情况下启动插页式广告?
此人响应也是你:http://stackoverflow.com/ a/35362973/513570 – Miquel
我添加了'autoShow':false和showInterstitialAd(),广告不再在启动时显示,但它也不会在第2级后显示 – cw24
您确定showInterstitialAd()为ca大会另作?另外,你确定你有广告展示吗? – Miquel