Adding Admob to Ionic?

2

I'm trying to put monetization in my ionic app. Searching, I found some examples but I'm not getting it to work. The banner simply does not appear.

Follow this example , which is quite simple, but I can not get it to work, the banner does not appear.

How to put admob in ionic applications?

    
asked by anonymous 15.12.2015 / 17:22

1 answer

1

Here is a link to a complete example of integration: link

Integration example:

var admobApp = angular.module('myapp', ['ionic'])
    .run(function($ionicPlatform, $ionicPopup) {
        $ionicPlatform.ready(function() {
            if(window.plugins && window.plugins.AdMob) {
                var admob_key = device.platform == "Android" ? "ANDROID_PUBLISHER_KEY" : "IOS_PUBLISHER_KEY";
                var admob = window.plugins.AdMob;
                admob.createBannerView( 
                    {
                        'publisherId': admob_key,
                        'adSize': admob.AD_SIZE.BANNER,
                        'bannerAtTop': false
                    }, 
                    function() {
                        admob.requestAd(
                            { 'isTesting': false }, 
                            function() {
                                admob.showAd(true);
                            }, 
                            function() { console.log('failed to request ad'); }
                        );
                    }, 
                    function() { console.log('failed to create banner view'); }
                );
            }
        });
    });
    
16.12.2015 / 12:26