此代码无法在iPhone上运行,但它可以在Android手机上运行。为什么呢?
function MyCtrl($scope){
$scope.title = "ADMOB XDK";
$scope.abrir = function(valor){
var admobid = {};
if( /(android)/i.test(navigator.userAgent) ) {
admobid = { // for Android
banner: 'ca-app-pub-5323315994691685/5395031531',
interstitial: 'ca-app-pub-5323315994691685/5395031531'
};
} else if(/(ipod|iphone|ipad)/i.test(navigator.userAgent)) {
admobid = { // for iOS
banner: 'ca-app-pub-5323315994691685/3239667139',
interstitial: 'ca-app-pub-5323315994691685/3239667139'
};
} else {
admobid = { // for Windows Phone
banner: 'ca-app-pub-5323315994691685/5395031531',
interstitial: 'ca-app-pub-5323315994691685/5395031531'
};
}
if(( /(ipad|iphone|ipod|android|windows phone)/i.test(navigator.userAgent) )) {
document.addEventListener('deviceready', initApp, false);
} else {
initApp();
}
function initApp() {
if (! AdMob ) { alert( 'admob plugin not ready' ); return; }
if(valor == 1){
AdMob.createBanner( {
adId: admobid.banner,
isTesting: true,
overlap: false,
offsetTopBar: false,
position: AdMob.AD_POSITION.BOTTOM_CENTER,
bgColor: 'black'
} );
}else{
AdMob.prepareInterstitial({
adId: admobid.interstitial,
autoShow: true
});
}
}
}
}