Cordova app not showing apps using admob-plus-cordova

53 Views Asked by At

Ads are not showing using this plugin. Let me describe the steps I followed from scratch, maybe you can assist me.
First, I created a new cordova project:

cordova create AdmobProject
cd AdmobProject

Then, I add the plugin

cordova plugin add admob-plus-cordova --save --variable APP_ID_ANDROID=ca-app-pub-3940256099942544~3347511713

I got this ID from Google website. Then, I modify the index.html inside AdmobProject/www folder. I leave it like this:

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="format-detection" content="telephone=no">
    <meta name="msapplication-tap-highlight" content="no">
    <meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover">
    <meta name="color-scheme" content="light dark">
    <link rel="stylesheet" href="css/index.css">
    <title>Joputa</title>
</head>

<body>
    <script src="cordova.js"></script>
</body>

</html>

And now I follow the instructions from plugin website and add the instructions for the banner. The index.html file is now:

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="format-detection" content="telephone=no">
    <meta name="msapplication-tap-highlight" content="no">
    <meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover">
    <meta name="color-scheme" content="light dark">
    <link rel="stylesheet" href="css/index.css">
    <title>Joputa</title>
</head>

<body>
    <script src="cordova.js"></script>
    <script>
        let banner

        document.addEventListener('deviceready', async () => {
            banner = new admob.BannerAd({
                adUnitId: 'ca-app-pub-3940256099942544/6300978111',
            })

            banner.on('impression', async (evt) => {
                await banner.hide()
            })

            await banner.show()
        }, false)
    </script>
</body>

</html>

I entered the test unitAdId provided by plugin website.
When I add android platform and build using cordova, the app does not display anything at all.
Suggestions about how to fix this, please?

0

There are 0 best solutions below