I'm baffled.
I'm using this plugin: http://ngcordova.com/docs/plugins/adMob/
I've got this code in my .run :
var admobid = {};
if( /(android)/i.test(navigator.userAgent) ) { // for android
admobid = {
banner: 'ca-app-pub-mycode',
interstitial: 'ca-app-pub-mycode'
};
} else if(/(ipod|iphone|ipad)/i.test(navigator.userAgent)) { // for ios
admobid = {
banner: 'ca-app-pub-mycode',
interstitial: 'ca-app-pub-mycode'
};
} else { // for windows phone
admobid = {
banner: 'ca-app-pub-mycode,
interstitial: 'ca-app-pub-mycode'
};
}
if(typeof AdMob !== "undefined") AdMob.createBanner( {
adId: admobid.banner,
position: AdMob.AD_POSITION.BOTTOM_CENTER,
autoShow: true } );
else alert("Admob is not defined");
})
I'm testing this on and android phone and I just get nothing. I've installed the plugin, I have ngCordova installed, I have the js reference in my index.html, have 'ngCordova' set as a dependency. What am I doing wrong? I've followed the instructions in the official docs exactly:
https://github.com/floatinghotpot/cordova-admob-pro
The error message doesn't come up and I'm using my real admob codes not the placeholder I've put here.
Any ideas?
Edit: I've no idea why it works now, but it does. I didn't change this code so it must have been something else.
I've found useful instructions here: https://github.com/appfeel/admob-google-cordova/wiki/Angular.js,-Ionic-apps
It's not ngCordova but it's working fine for me.
It seems I just had to wait 24hrs for my adMob set-up to "propagate" properly.
Check this post: http://redwanhilali.com/ionic-admob-integration/ you have to wrap it within $ionicPlatform.ready call
All the ad initialisation code should be in the $ionicPlatform.ready() function in the app.js file
here is the full code for the app.js file for the tabs project.
NOTE: The app.js file will be a bit different for side-menu and Tabs Projects so make sure you edit carefully
Full Tutorial Here:
http://pointdeveloper.com/how-to-add-banner-ads-to-ionic-apps-using-admob-pro-plugin/