al3x
al3x

Reputation: 11

Problem with interstitial in admob-plus-cordova 2.0.0-alpha.19

I have some issue and I have been struggling with this problem for a long time...

My code:

<button class="sem-show-ad">Show ad</button>
<script src="cordova.js"></script>
<script>

    document.addEventListener('deviceready', () => {
        window.admob.start();
    });

    let interstitial
    document.addEventListener('deviceready', () => {
        alert(window.admob);
        document.querySelector(".sem-show-ad").addEventListener("click", async () => {
            console.log("window.admob:", window.admob);

            interstitial = new window.admob.InterstitialAd({
                adUnitId: 'ca-app-pub-3940256099942544/1033173712', // test
            });

            interstitial.on('load', (evt) => {
                console.log("c: ", evt.ad);
            });

            console.log("interstitial: ",interstitial);

            await interstitial.load();
            await interstitial.show();

            interstitial.on('loadFail', (err) => {
                console.error("Failed to load ad:", err);
            });

            interstitial.on('showFail', (err) => {
                console.error("Failed to show ad:", err);
            });
        });
    }, false);

    document.addEventListener('admob.ad.dismiss', async () => {
        // Once a interstitial ad is shown, it cannot be shown again.
        // Starts loading the next interstitial ad as soon as it is dismissed.
        await interstitial.load()
    })
</script>

I can't show interstitial ad, I have no Idea why, I asked chat GPT but it didn't help me... I was based on documentation: https://admob-plus.github.io/docs/cordova/ads/interstitial

I have tried to debug in many ways, for example connecting my mobile device to my computer and debugging through the chrome console, but I do not get any errors

Before I used admob-plus-cordova 1.28.0 and everything worked, but I got a message from google play console that I have to update my plugins:

com.google.android.gms:play-services-ads-lite:20.6.0 The creator of the Google Mobile Ads (GMA) SDK package (com.google.android.gms:play-services-ads-lite) added this notice to version 20.6.0:

As of June 30th 2024, this version is sunset. For more information, please visit https://developers.google.com/admob/android/deprecation.

From May 20, 2025, at 00:00 (UTC), it will no longer be possible to publish new versions of applications containing this version of the SDK package on the production track or the open testing track.

Upvotes: 0

Views: 23

Answers (0)

Related Questions