cordova create oooxxxx
see js/index.js
onDeviceReady: function() {
app.receivedEvent('deviceready');
}
Now put AdMob Code
onDeviceReady: function() {
// place our admob ad unit id here
var admobid = {};
if( /(android)/i.test(navigator.userAgent) ) {
admobid = { // for Android
banner: 'ca-app-pub-xxxxxxxxxxxxx/oooooooooooo',
interstitial: 'ca-app-pub-xxxxxxxxxxxxx/oooooooooooo'
};
} else if(/(ipod|iphone|ipad)/i.test(navigator.userAgent)) {
admobid = { // for iOS
banner: 'ca-app-pub-xxxxxxxxxxxxx/oooooooooooo',
interstitial: 'ca-app-pub-xxxxxxxxxxxxx/oooooooooooo'
};
} else {
admobid = { // for Windows Phone
banner: 'ca-app-pub-xxxxxxxxxxxxx/oooooooooooo',
interstitial: 'ca-app-pub-xxxxxxxxxxxxx/oooooooooooo'
};
}
if (! AdMob ) { alert( 'admob plugin not ready' ); return; }
// this will create a banner on startup
AdMob.createBanner( {
adId: admobid.banner,
adSize: 'SMART_BANNER',
position: AdMob.AD_POSITION.BOTTOM_CENTER,
isTesting: true, // TODO: remove this line when release
overlap: false,
offsetTopBar: false,
bgColor: 'black'
} );
this will load a full screen ad on startup
AdMob.prepareInterstitial({
adId: admobid.interstitial,
isTesting: true, // TODO: remove this line when release
autoShow: true
});
app.receivedEvent('deviceready');
}
PS:If see example https://github.com/floatinghotpot/cordova-admob-pro/blob/master/test/index.html
Maybe this need to change
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; media-src *">
reference
https://www.npmjs.com/package/cordova-plugin-admobpro
https://github.com/floatinghotpot/cordova-admob-pro/blob/master/test/index.html
https://github.com/floatinghotpot/cordova-admob-pro/blob/master/test/admob_simple.js