我希望你能帮助我解决这个问题。我已经试过各种过去5天,但我不能每次。我已经使用buildt HTML5,CSS和Javascript.The应用的点点简单的应用程序作品fine.Than我想简单的横幅广告,显示在app.I的底部就不能得到它的工作。有时,一个黑盒子显示了底部,这一切,而不是广告。我不是很好的JavaScript,所以这个问题是莫比的代码,但是我已经复制大部分来自插件为例。
来源:https://www.npmjs.com/package/phonegap-admob
我使用的是: - PhoneGap的6.1.2(构建服务) - AdMob的-的PhoneGap plugin(<plugin name="phonegap-admob" spec="4.2.1" />)
- 那做工精细的其他插件。
我需要: - 只有一小横幅广告在页面的底部。
平台: - 仅适用于Android
在我的config.xml中我有这样一行:
<plugin name="phonegap-admob" spec="4.2.1" />
在我的<script></script>
标签内的index.html,我有这样的代码:
<script>
var isAppForeground = true;
function initAds() {
if (admob) {
var adPublisherIds = {
android : {
banner : "ca-app-pub-1467389904102750/404191XXXX",
}
};
var admobid = (/(android)/i.test(navigator.userAgent)) ? adPublisherIds.android : adPublisherIds.ios;
admob.setOptions({
publisherId: admobid.banner,
interstitialAdId: admobid.interstitial,
});
registerAdEvents();
} else {
alert('AdMobAds plugin not ready');
}
}
function onAdLoaded(e) {
if (isAppForeground) {
if (e.adType === admob.AD_TYPE.INTERSTITIAL) {
console.log("An interstitial has been loaded and autoshown. If you want to load the interstitial first and show it later, set 'autoShowInterstitial: false' in admob.setOptions() and call 'admob.showInterstitialAd();' here");
} else if (e.adType === admob.AD_TYPE_BANNER) {
console.log("New banner received");
}
}
}
function onPause() {
if (isAppForeground) {
admob.destroyBannerView();
isAppForeground = false;
}
}
function onResume() {
if (!isAppForeground) {
setTimeout(admob.createBannerView, 1);
setTimeout(admob.requestInterstitialAd, 1);
isAppForeground = true;
}
}
// optional, in case respond to events
function registerAdEvents() {
document.addEventListener(admob.events.onAdLoaded, onAdLoaded);
document.addEventListener(admob.events.onAdFailedToLoad, function (e) {});
document.addEventListener(admob.events.onAdOpened, function (e) {});
document.addEventListener(admob.events.onAdClosed, function (e) {});
document.addEventListener(admob.events.onAdLeftApplication, function (e) {});
document.addEventListener("pause", onPause, false);
document.addEventListener("resume", onResume, false);
}
function onDeviceReady() {
document.removeEventListener('deviceready', onDeviceReady, false);
initAds();
// display a banner at startup
admob.createBannerView();
}
document.addEventListener("deviceready", onDeviceReady, false);
</script>
我希望有一个人可以帮助我。非常感谢