huedawn-plugin-admob-free
Version:
Robust, reliable and easy to use Cordova Admob plugin for Android, iOS and Windows phone. Allows preloading and automatic loading of interstitials and banners plus more.
52 lines (42 loc) • 1.26 kB
JavaScript
var admobid = {}
if (/(android)/i.test(navigator.userAgent)) { // for android & amazon-fireos
admobid = {
banner: 'ca-app-pub-3940256099942544/6300978111',
interstitial: 'ca-app-pub-3940256099942544/1033173712',
}
} else if (/(ipod|iphone|ipad)/i.test(navigator.userAgent)) { // for ios
admobid = {
banner: 'ca-app-pub-3940256099942544/2934735716',
interstitial: 'ca-app-pub-3940256099942544/4411468910',
}
}
document.addEventListener('deviceready', function() {
AdMob.setOptions({
isTesting: true,
})
AdMob.createBannerView({
autoShow: true,
});
AdMob.prepareInterstitial({
adId: admobid.interstitial,
autoShow: false,
})
document.getElementById('showAd').disabled = true
document.getElementById('showAd').onclick = function() {
AdMob.showInterstitial()
}
}, false)
document.addEventListener('onFailedToReceiveAd', function(event) {
console.log(event)
})
document.addEventListener('onReceiveInterstitialAd', function(event) {
console.log(event)
document.getElementById('showAd').disabled = false
})
document.addEventListener('onDismissInterstitialAd', function(event) {
console.log(event)
AdMob.prepareInterstitial({
adId: admobid.interstitial,
autoShow: false,
})
})