Question

I am using this admob cordova plugin. I've installed the plugin in Icenium and put the javascript code in the body:

document.addEventListener('deviceready', function () {
if (window.plugins && window.plugins.AdMob) {
    var admob_ios_key = 'xxxxxxxxxxxxxxx';
    var admob_android_key = 'xxxxxxxxxxxxxxx';
    var adId = (navigator.userAgent.indexOf('Android') >= 0) ? admob_android_key : admob_ios_key;
    var am = window.plugins.AdMob;

    am.createBannerView(
        {
            'publisherId': adId,
            'adSize': am.AD_SIZE.BANNER,
            'bannerAtTop': false
        },
         function () {
              am.requestAd(
                { 'isTesting': true },
                    function () {
                        am.showAd(true);
                    },
                    function () { alert('failed to request ad'); }
                );
            },
            function () { alert('failed to create banner view'); }
        );
} else {
    alert('AdMob plugin not available/ready.');
}

});

My problem is that I don't see the ad, but just a black rectangle placeholder at the bottom of the screen.

I wanted to know why it doesn't show the ad, and if that's have to do with the asmob_ios_key and admob_android_key, I want to know what to put there. I put my admob publisher id number (without the 'pub-'), but I am not sure that this what I should put in the field

Was it helpful?

Solution

I know this is old but i have just installed this on xcode, using cordova 3.3.0. I used my publisher id. began with an 'a'. I did have it in wrong and i got a blank black screen at the bottom, actually had some spaces between the '' marks

OTHER TIPS

the most possible reason for a blank/black ad is caused by a wrong ad unit id.

hi, i am the author of the plugin. though the variable is named as "publisherId" for historical reason, the real purpose is an Ad Unit Id, in following format:

         var ad_units = {
            ios : {
                banner: 'ca-app-pub-xxx/4806197152',
                interstitial: 'ca-app-pub-xxx/7563979554'
            },
            android : {
                banner: 'ca-app-pub-xxx/9375997553',
                interstitial: 'ca-app-pub-xxx/1657046752'
            }
        };
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top