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 always fails to load #290

Open zronn opened 6 years ago

zronn commented 6 years ago

Here is the code I'm using to prepare the interstitial ad :

_showInterstitial() {
    let interstitialConfig: AdMobFreeInterstitialConfig = {
        isTesting: true,
        autoShow: false,
        // id: 'ca-app-pub-xxx'
    };
    this.adMobFree.interstitial.config(interstitialConfig);

    this.adMobFree.interstitial.prepare().then(p => {
        console.log('Intertistial prepared.');
        console.log(p);
    }).catch(e => console.log(e));
}

At this point, the interstitial is correctly prepared. Then, two listener are setted to check if the ad correctly loaded, and another one if it failed :

// Listen when the Interstitial is loaded
this.admobLoad = this.adMobFree.on(this.adMobFree.events.INTERSTITIAL_LOAD).subscribe(() => {
    console.log('Event interstitial loaded.');
    this.adMobFree.interstitial.show().then(() => {
        // Show successful
    }).catch((errorShow) => {
        console.log(errorShow);
    });
    this.admobLoad.unsubscribe();
});

// Listen when the Interstitial has failed to load
this.admobFail = this.adMobFree.on(this.adMobFree.events.INTERSTITIAL_LOAD_FAIL).subscribe(res => {
    console.log('Interstitial load fail.');
    console.log(res);
    this.admobFail.unsubscribe();
});

In my case, it always failed. Here is the response from the listener :

Event {
    adType: "interstitial"
    bubbles: false
    cancelBubble: false
    cancelable: false
    composed: false
    currentTarget: null
    defaultPrevented: false
    error: 0
    eventPhase: 0
    isTrusted: false
    path: (2) [document, Window]
    reason: "Internal error"
    returnValue: true
    srcElement: document
    target: document
    timeStamp: 66483.19999995874
    type: "admob.interstitial.events.LOAD_FAIL"
}

Thanks for your help.

jony89 commented 6 years ago

@ratson same as #184

zronn commented 6 years ago

In my case, ads are not showing even in test mode

jony89 commented 6 years ago

So you probably have some other issue. I've reinstalled all from scratch and test is working without any issue.

This is my code :

window.admob.interstitial.config({
    id: INTERSTITIAL_AD_ID,
});

// Create banner
await window.admob.interstitial.prepare();

document.addEventListener('admob.interstitial.events.LOAD', () => {
    window.admob.interstitial.show();
});