Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the ad-inserter domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/vhosts/blog.webeats.it/httpdocs/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the cookie-law-info domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/vhosts/blog.webeats.it/httpdocs/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wordpress-seo domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/vhosts/blog.webeats.it/httpdocs/wp-includes/functions.php on line 6114
Plugin AdMob: Aggiungere pubblicità AdMob su app ionic

Plugin AdMob: Aggiungere pubblicità AdMob ai nostri progetti ionic o cordova

Installiamo il plugin AdMob per inserire i banner pubblicitari nelle nostre app realizzate con ionic (cordova) in pochi semplici passi

Dopo esserci registrati su su https://apps.admob.com/, creato le varie Unità pubblicitarie (hanno un codice tipo questo ca-app-pub-xxx/yyy) e aggiunte una o più piattaforme al nostro progetto, nel seguente modo

ionic platform add ios
ionic platform add android

possiamo procedere all’installazione del plugin AdMob per far apparire i banner e gli ads interstitial (maggiori informazioni):

ionic plugin add com.google.cordova.admob

Fatto questo, non ci resta che aggiungere questo codice dopo $ionicPlatform.ready() nel nostro app.js o main.js

var admobid = {};
        // select the right Ad Id according to platform
        if( /(android)/i.test(navigator.userAgent) ) { 
            admobid = { // for Android
                banner: 'ca-app-pub-xxx/yyy',
                interstitial: 'ca-app-pub-xxx/yyy'
            };
        } else if(/(ipod|iphone|ipad)/i.test(navigator.userAgent)) {
            admobid = { // for iOS
                banner: 'ca-app-pub-xxx/yyy',
                interstitial: 'ca-app-pub-xxx/yyy'
            };
        } else {
            admobid = { // for Windows Phone
                banner: 'ca-app-pub-xxx/yyy',
                interstitial: 'ca-app-pub-xxx/yyy'
            };
        }
 
  if(window.AdMob) AdMob.createBanner( {
      adId:admobid.banner, 
      position:AdMob.AD_POSITION.BOTTOM_CENTER, 
      autoShow:true} );

Usi ionic 2? Segui questa guida per usare il anche sulla v2 il plugin AdMob