我试图使用Cordova AdMob插件https://github.com/appfeel/admob-google-cordova使AdMob在可加载网页的Cordova Android应用上正常工作。
我将Google admob AppID赋予了代码的PublisherID。应用程序在移动设备上没有显示广告。
下面给出了代码。
var app = {
// Application Constructor
initialize: function() {
document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
},
// deviceready Event Handler
//
// Bind any cordova events here. Common events are:
// 'pause', 'resume', etc.
onDeviceReady: function() {
this.receivedEvent('deviceready');
if (navigator.connection.type == Connection.NONE) {
navigator.notification.alert('Check your internet connection!');
} else {
window.location="http://www.xxxxyyyyyzzzz.com";
}
// start of admob code
admob.createBannerView({publisherId: "ca-app-pub-2275440647866479/xxxxxxxxxxx"});
// end of admob code
},
// Update DOM on a Received Event
receivedEvent: function(id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
console.log('Received Event: ' + id);
}
};
app.initialize();
无错误消息。 android手机上没有广告。