Last active
February 15, 2019 15:43
-
-
Save imelgrat/440fdc91af39a4372232d3709db5ef76 to your computer and use it in GitHub Desktop.
Configure AdMob ads on a Phonegap application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Define the right AdMob ID according to mobile platform (Banner and Intersitial types) | |
* | |
* @link https://imelgrat.me/phonegap/admob-effective-monetize-cordova-app/ | |
* | |
* @link https://goo.gl/yTCAea AdMob Plugin Pro | |
* | |
*/ | |
var admobid = {}; | |
if (/(android)/i.test(navigator.userAgent)) { | |
// for android | |
admobid = { | |
banner: "ca-app-pub-xxx/zzz", // or DFP format "/mmmmmmm/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 "/mmmmmmm/dfp_example_ad" | |
interstitial: "ca-app-pub-xxx/kkk" | |
}; | |
} else { | |
// for windows phone | |
admobid = { | |
banner: "ca-app-pub-xxx/zzz", // or DFP format "/mmmmmmm/dfp_example_ad" | |
interstitial: "ca-app-pub-xxx/kkk" | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create an AdMob intersitial ad using AdMob Plugin Pro (in Phohegap) | |
* | |
* @link https://imelgrat.me/phonegap/admob-effective-monetize-cordova-app/ | |
* | |
* @link https://goo.gl/yTCAea AdMob Plugin Pro | |
* | |
*/ | |
function prepareInterstitial() | |
{ | |
AdMob.prepareInterstitial({ adId:admobid.interstitial, autoShow:true }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment