joseph
joseph

Reputation: 21

AdMob Ads Not Displaying in Cordova App(Html,css,js)

I'm developing a Cordova app using HTML, CSS, and JavaScript, and I'm trying to integrate AdMob ads using the admob-plus-cordova plugin. However, the ads are not displaying on my device.

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AdMob Plus Example</title>
</head>

<body>
    <h1>Hello, AdMob!</h1>

    <script type="text/javascript">

        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>

Despite these efforts, the ads still aren't displaying. Any insights or suggestions on what might be going wrong would be greatly appreciated!

Upvotes: 1

Views: 32

Answers (1)

Eric
Eric

Reputation: 10658

It looks like you might have skipped a step, which is to start the plugin, as per the documentation. Try

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

Upvotes: 0

Related Questions