我正在尝试将广告添加到我的 android phonegap 应用程序,但我没有得到任何结果......我使用 phonegap 0.3.3
我的 admob key 广告 key 如下:ca-app-pub-9718633180389415/1973821888
我的 config.xml 我有:
<plugin name="com.admob.google" spec="4.0.8" source="pgb" />
然后在我的索引上试了一下:
function onDeviceReady() {
document.removeEventListener('deviceready', onDeviceReady, false);
// Set AdMobAds options:
admob.setOptions({
publisherId: "ca-app-pub-9718633180389415/1973821888", // Required
interstitialAdId: "ca-app-pub-9718633180389415/1973821888", // Optional
tappxIdiOs: "/XXXXXXXXX/Pub-XXXX-iOS-IIII", // Optional
tappxIdAndroid: "/XXXXXXXXX/Pub-XXXX-Android-AAAA", // Optional
tappxShare: 0.5 // Optional
});
// Start showing banners (atomatic when autoShowBanner is set to true)
admob.createBannerView();
// Request interstitial (will present automatically when autoShowInterstitial is set to true)
admob.requestInterstitial();
}
但注意显示: 我正在使用 https://github.com/sunnycupertino/cordova-plugin-admob-simple
最佳答案
作者 cordova-admob
插件在这里。您是否尝试过 isTesting: true
?你在真实设备上运行吗?请注意,它不适用于浏览器(仅限模拟器或真实设备)。
在你的config.xml
中:
<gap:plugin name="phonegap-admob" source="npm"/>
在你的 javascript 中:
function onDeviceReady() {
document.removeEventListener('deviceready', onDeviceReady, false);
// Set AdMobAds options:
admob.setOptions({
publisherId: "ca-app-pub-XXXXXXXXXXXXXXXX/BBBBBBBBBB", // Required
interstitialAdId: "ca-app-pub-XXXXXXXXXXXXXXXX/IIIIIIIIII", // Optional
isTesting: true // Optional
});
// Start showing banners (atomatic when autoShowBanner is set to true)
admob.createBannerView();
// Request interstitial (will present automatically when autoShowInterstitial is set to true)
admob.requestInterstitialAd();
}
document.addEventListener("deviceready", onDeviceReady, false);
在此处查看更多详细信息:https://github.com/appfeel/admob-google-cordova/wiki/Setup
关于javascript - Admob 不适用于 phonegap 和 android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38059587/