我有一个简单的测试项目phonegap,
我想测试我的AdMob帐户。
我执行了nodeJS命令行的所有以下指令:
D:\ prova> cordova创建prova2 io.prova.prova ProvaApp创建一个新的 科尔多瓦项目。
D:\ prova> cd prova2
D:\ prova \ prova2> cordova插件添加cordova-plugin-admobpro添加 cordova-plugin-admobpro to package.json保存的插件信息 “cordova-plugin-admobpro”到config.xml
d:\ PROVA \ prova2>
在线上构建并在我的设备中安装后,它返回错误:“admob未定义” 这是我的Html页面的代码:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta http-equiv="Content-Security-Policy" content="default-src * data: content: gap: https://ssl.gstatic.com; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'">
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script>
function initAds() {
if (admob) {
var adPublisherIds = {
ios : {
banner : "ca-app-pub-2598287637019590/*********",
interstitial : "ca-app-pub-2598287637019590/*********"
},
android : {
banner : "ca-app-pub-2598287637019590/*******",
interstitial : "ca-app-pub-2598287637019590/******"
}
};
var admobid = (/(android)/i.test(navigator.userAgent)) ? adPublisherIds.android : adPublisherIds.ios;
admob.setOptions({
publisherId: admobid.banner,
interstitialAdId: admobid.interstitial,
// tappxIdiOS: "/XXXXXXXXX/Pub-XXXX-iOS-IIII",
// tappxIdAndroid: "/XXXXXXXXX/Pub-XXXX-Android-AAAA",
tappxShare: 0.5
});
registerAdEvents();
} else {
alert('AdMobAds plugin not ready');
}
}
function onAdLoaded(e) {
if (e.adType === admob.AD_TYPE.INTERSTITIAL) {
admob.showInterstitialAd();
showNextInterstitial = setTimeout(function() {
admob.requestInterstitialAd();
}, 2 * 60 * 1000); // 2 minutes
}
}
// 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(admob.events.onInAppPurchaseRequested, function (e) {});
}
function onDeviceReady() {
document.removeEventListener('deviceready', onDeviceReady, false);
try {
initAds();
}
catch(err) {
alert(err.message);
}
// display a banner at startup
admob.createBannerView();
// request an interstitial
admob.requestInterstitialAd();
}
document.addEventListener("deviceready", onDeviceReady, false);
</script>
</head>
<body>
</body>
</html>
这里有什么问题?