ratson / cordova-plugin-admob-free

New development has been moved to "admob-plus-cordova", https://github.com/admob-plus/admob-plus/tree/master/packages/cordova
https://github.com/admob-plus/admob-plus
MIT License
494 stars 210 forks source link

Interstitial Ad not showing #52

Closed Script47 closed 7 years ago

Script47 commented 7 years ago

Since the update, my ads won't show for some reason, my code is as shown below.

 admob.interstitial.config({
        id: 'my-id',
        isTesting: false
 });

admob.interstitial.prepare();

admob.interstitial.show();

Any ideas?

ratson commented 7 years ago

Are you calling admob.interstitial.show() immediately? Please have a look on the example, see if you code has any difference.

Script47 commented 7 years ago

@ratson Is there an event for me to use to check if the ad is ready?

In my code, I'm not immediately calling it, it only runs if a condition is met which happens later on in the app.

vintage commented 7 years ago

@Script47 In current version you could simply use:

admob.interstitial.prepare();
document.addEventListener('admob.interstitial.events.LOAD', function(event) {
  admob.interstitial.show();
})

In the next release you will be able to prepare the interstitial and checks if it's ready on-demand using admob.interstitial.isReady().then(isReady => console.log("Am I ready?", isReady)).

Also check the docs https://ratson.github.io/cordova-plugin-admob-free/variable/index.html#static-variable-interstitial and examples pointed out by ratson.

Script47 commented 7 years ago

@vintage @ratson Odd... I have all the events, but no errors are showing at all, neither is the ad, the is as you can see below, one other thing is that I don't actually have access to the console hence I used the error event, but still nothing shows.

admob.interstitial.prepare()

document.addEventListener('admob.interstitial.events.LOAD_FAIL', function (e) {
    swal({
        'title': 'Admob Error',
        'html': e,
        'type': 'error'
    });
});

/** interstitial has loaded successfully **/
document.addEventListener('admob.interstitial.events.LOAD', function () {
        admob.interstitial.show();
});

/** On interstitial close, reprepare. **/
document.addEventListener('admob.interstitial.events.CLOSE', function () {
    admob.interstitial.prepare()
});
Script47 commented 7 years ago

@ratson @vintage

Bump - Still not working, any ideas?

vintage commented 7 years ago

@Script47

Does this one works for you?

admob.interstitial.config({
        id: <PUT_YOUR_ID>,
        isTesting: true,
        autoShow: true
      });
admob.prepare();

If not, what errors shows on the browser console or xcode/adb console?

Script47 commented 7 years ago

Update

For those of you who (like me) were struggling to get this to work using Intel XDK should note that you use use deviceready instead of the app.Ready function, this was causing the plugin not to work for me.