setInterval(showInterstitialAd, 120000);
はどこに置くべきですか? admobを使用して、私のphonegapアプリで2分ごとにインタースティシャル広告を作成するために、以下のコードを使用したいと思います。 「;いくつかの詳細を追加してくださいあなたのポストは、ほとんどのコードであるように見えます。」、ので... <gap:plugin name="phonegap-admob" source="npm"/>
PhonegapのAdMob修正
var isPendingInterstitial = false;
var isAutoshowInterstitial = false;
function prepareInterstitialAd() {
if (!isPendingInterstitial) {
admob.requestInterstitialAd({
autoShowInterstitial: isAutoshowInterstitial
});
}
}
function onAdLoadedEvent(e) {
if (e.adType === admob.AD_TYPE.INTERSTITIAL && !isAutoshowInterstitial) {
isPendingInterstitial = true;
}
}
function onDeviceReady() {
document.removeEventListener('deviceready', onDeviceReady, false);
admob.setOptions({
publisherId: "ca-app-pub-XXXXXXXXXXXXXXXX/BBBBBBBBBB",
interstitialAdId: "ca-app-pub-XXXXXXXXXXXXXXXX/IIIIIIIIII",
});
document.addEventListener(admob.events.onAdLoaded, onAdLoadedEvent);
prepareIntestitialAd();
}
document.addEventListener("deviceready", onDeviceReady, false);
function showInterstitialAd() {
if (isPendingInterstitial) {
admob.showInterstitialAd(function() {
isPendingInterstitial = false;
isAutoshowInterstitial = false;
prepareInterstitialAd();
});
} else {
// The interstitial is not prepared, so in this case, we want to show the interstitial as soon as possible
isAutoshowInterstitial = true;
admob.requestInterstitialAd({
autoShowInterstitial: isAutoshowInterstitial
});
}
}
:私は、次のプラグインを使用します