X 次点击后如何显示插页式广告
How to show InterstitialAd after X amout of clicks
我使用的是cordova-plugin-admob-free,当变量totalQuestions第一次等于6时,它显示InterstitialAd没有问题,然后变量变为0,再点击6次后,广告获胜显示。我究竟做错了什么?我想我必须请求一个新广告或者做一些不同的事情?
在 JS 文件的顶部我有这个:
// Wait for device API libraries to load
document.addEventListener("deviceready", onDeviceReady, false);
// device APIs are available
function onDeviceReady() {
admob.interstitial.config({
id: 'ca-app-pub-9044971602164437/7052812839',
autoShow: false
});
admob.interstitial.prepare();
}
我还有这个功能:
$(".truth-btn, .dare-btn").on("click", function (event) {
totalQuestions++;
if (totalQuestions == 6) {
admob.interstitial.show();
totalQuestions = 0;
}
});
您需要再准备一个像这样的插页式广告
let totalQuestions=0;
$(".dare-btn").on("click", function (event) {
totalQuestions++;
console.log(totalQuestions);
if (totalQuestions == 6) {
admob.interstitial.show();
totalQuestions = 0;
setTimeout(() => {
admob.interstitial.prepare();
}, 2000);
}
});
and it is better to use localstorage to save the value of totalQuestions
我使用的是cordova-plugin-admob-free,当变量totalQuestions第一次等于6时,它显示InterstitialAd没有问题,然后变量变为0,再点击6次后,广告获胜显示。我究竟做错了什么?我想我必须请求一个新广告或者做一些不同的事情?
在 JS 文件的顶部我有这个:
// Wait for device API libraries to load
document.addEventListener("deviceready", onDeviceReady, false);
// device APIs are available
function onDeviceReady() {
admob.interstitial.config({
id: 'ca-app-pub-9044971602164437/7052812839',
autoShow: false
});
admob.interstitial.prepare();
}
我还有这个功能:
$(".truth-btn, .dare-btn").on("click", function (event) {
totalQuestions++;
if (totalQuestions == 6) {
admob.interstitial.show();
totalQuestions = 0;
}
});
您需要再准备一个像这样的插页式广告
let totalQuestions=0;
$(".dare-btn").on("click", function (event) {
totalQuestions++;
console.log(totalQuestions);
if (totalQuestions == 6) {
admob.interstitial.show();
totalQuestions = 0;
setTimeout(() => {
admob.interstitial.prepare();
}, 2000);
}
});
and it is better to use localstorage to save the value of totalQuestions