function initAd() {
// it will display smart banner at top center, using the default options
if(AdMob) AdMob.createBanner( {
adId: admobid.banner,
bannerId: admobid .banner,
position: AdMob.AD_POSITION.BOTTOM_CENTER,
autoShow: true,
isTesting: false,
success: function() {
console.log(' banner created');
},
error: function() {
console.log('failed to create banner');
}
});< br />
window.AdMob.prepareInterstitial({
adId:admobid.interstitial, autoShow:false
});
window.AdMob.showInterstitial();
}
Is there a way to display a partial ad every 2 minutes? Someone told me to add this: setInterval(showInterstitial,1 * 60 * 1000), but I don’t know where to add it?
setInterval(window.AdMob.showInterstitial, 2*60*1000);
You should add it before the closing parenthesis of the initAdd function:
function initAd(){
// it will display smart banner at top center, using the default options
if(AdMob) AdMob. createBanner( {
adId: admobid.banner,
bannerId: admobid.banner,
position:AdMob.AD_POSITION.BOTTOM_CENTER,
autoShow: true,
isTesting: false ,
success: function(){
console.log('banner created');
},
error: function(){
console.log(' failed to create banner');
}
} );
window.AdMob.prepareInterstitial(
{adId:admobid.interstitial, autoShow:false} );
window.AdMob.showInterstitial();
//!!!add the code here!!!-so, just paste what I wrote above:
setInterval(window.AdMob.showInterstitial, 2*60*1000);
}
You can see a simple setInterval usage on this jsFiddle example:
function a(){
alert("hi every 2 seconds");
};
setInterval(a, 2*1000);
The reason why you should not call it this way (note the parentheses after a ): setInterval(a(),2 * 1000); then your function will only be called once (you will see only a warning pop up). jsFiddle example:
function a(){
alert("hi every 2 seconds");
};
setInterval(a(), 2*1000);
< p>Hope this helps to clear up some things.
I use the AdMob plugin in Ionic and use this code to display an Interstital ad:
function initAd(){
// it will display smart banner at top center, using the default options
if(AdMob) AdMob.createBanner( {
adId: admobid.banner,
bannerId: admobid.banner,
position: AdMob.AD_POSITION.BOTTOM_CENTER,
autoShow: true,
isTesting: false,
success: function() {
console.log('banner created');
},
error: function() {
console.log('failed to create banner');
}
});
window.AdMob.prepareInterstitial({
adId:admobid.interstitial, autoShow:false
}) ;
window.AdMob.showInterstitial();
}
Is there a way to show a partial ad every 2 minutes? Someone told me to add this: setInterval(showInterstitial,1 * 60 * 1000), but I don’t know where to add it?
If you want to display every 2 minutes, you should use:
setInterval( window.AdMob.showInterstitial, 2*60*1000);
You should add it before the closing parenthesis of the initAdd function:
function initAd() {
// it will display smart banner at top center, using the default options
if(AdMob) AdMob.createBanner( {
adId: admobid.banner ,
bannerId: admobid.banner,
position:AdMob.AD_POSITION.BOTTOM_CENTER,
autoShow: true,
isTesting: false,
success: function(){< br /> console.log('banner created');
},
error: function(){
console.log('failed to create banner');
}
} );
window.AdMob.prepareIn terstitial(
{adId:admobid.interstitial, autoShow:false} );
window.AdMob.showInterstitial();
//! !!add the code here!!!-so, just paste what I wrote above:
setInterval(window.AdMob.showInterstitial, 2*60*1000);
}
You can see a simple setInterval usage on this jsFiddle example:
function a(){
alert("hi every 2 seconds" );
};
setInterval(a, 2*1000);
The reason why you should not call it this way (note the parentheses after a): setInterval( a(),2 * 1000); then your function will only be called once (you will see only a warning pop up). jsFiddle example:
function a( ){
alert("hi every 2 seconds");
};
setInterval(a(), 2*1000);
I hope this It helps to clear some things.