Skip to content

Instantly share code, notes, and snippets.

@imelgrat
Last active August 23, 2017 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imelgrat/4466c757573582f6898d to your computer and use it in GitHub Desktop.
Save imelgrat/4466c757573582f6898d to your computer and use it in GitHub Desktop.
JavaScript code to configure Cordova's AdMob Plugin Pro. Full articlle at: http://imelgrat.me/phonegap/admob-effective-monetize-cordova-app/
// select the right Ad ID according to platform
var admobid = {};
if( /(android)/i.test(navigator.userAgent) ){ // for android
admobid = {
banner: 'ca-app-pub-xxx/zzz', // or DFP format "/6253334/dfp_example_ad"
interstitial: 'ca-app-pub-xxx/kkk'
};
}
else if(/(ipod|iphone|ipad)/i.test(navigator.userAgent)){ // for ios
admobid = {
banner: 'ca-app-pub-xxx/zzz', // or DFP format "/6253334/dfp_example_ad"
interstitial: 'ca-app-pub-xxx/kkk'
};
}
else { // for windows phone
admobid = {
banner: 'ca-app-pub-xxx/zzz', // or DFP format "/6253334/dfp_example_ad"
interstitial: 'ca-app-pub-xxx/kkk'
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment