Adding Admob to the Ionic?

Asked

Viewed 810 times

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 just doesn’t appear.

I followed that example, that is pretty simple by the way, but I can’t make it work, the banner doesn’t appear.

How to put admob on Ionic applications ?

  • https://blog.nraboy.com/2014/06/using-admob-ionicframework/ who knows can help a little

  • @Otto worked like a charm. A doubt I have with respect to the banners, to better monetize I’ve heard that at each screen of the application I have to force the exchange of banner, so the $$ is better. This is true ? if it is how do I change the banners to each screen ? thank you

  • Fernando, post here after your feedback on this, I’m interested in this.

  • @Fernandopaiva speaks master added as an answer to help the crowd.

1 answer

1


Follow link with full integration example: https://blog.nraboy.com/2014/06/using-admob-ionicframework/

Example of integration:

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'); }
                );
            }
        });
    });

Browser other questions tagged

You are not signed in. Login or sign up in order to post.