Admob不支持phonegap和android
Admob not working in phonegap and android
我试图添加广告到我的android phonegap应用程序,但我没有得到任何…我使用phonegap 0.3.3
我的admob密钥AD密钥像: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
不确定这是否有用,但我认为我正在使用与您相同的插件,当,事实上,我正在使用这个:
https://github.com/admob-google/admob-cordova 为了使用这个插件,我写了以下代码:var AdmobManager = {
// admob configuration
admobCfg: {},
// Initialize admob support, and start showing a banner right away
initAdmob: function () {
// If we don't have admob support, don't try to configure anything
if (!admob)
return;
// Configure the IDs for the iOS and Android banner and interstitial ads
AdmobManager.admobCfg.iosCfg = {
banner: "ca-app-pub-XXXXXXXXXXXXXXXX/BBBBBBBBBB",
interstitial: "ca-app-pub-XXXXXXXXXXXXXXXX/IIIIIIIIII"
};
AdmobManager.admobCfg.androidCfg = {
banner: "ca-app-pub-XXXXXXXXXXXXXXXX/RRRRRRRRRR",
interstitial: "ca-app-pub-XXXXXXXXXXXXXXXX/HHHHHHHHHH"
};
// Choose ad IDs based on platform
AdmobManager.admobCfg.activeCfg = (/(android)/i.test(navigator.userAgent)) ? AdmobManager.admobCfg.androidCfg : AdmobManager.admobCfg.iosCfg;
// Now we can init admob: set the IDs, and build a param for testing mode
admob.initAdmob(AdmobManager.admobCfg.activeCfg.banner, AdmobManager.admobCfg.activeCfg.interstitial);
AdmobManager.admobCfg.extraParams = new admob.Params();
AdmobManager.admobCfg.extraParams.isTesting = true;
// Request banner ads immediately upon app start
admob.showBanner(admob.BannerSize.BANNER, admob.Position.BOTTOM_CENTER, AdmobManager.admobCfg.extraParams);
},
// start allowing Admob interstitials
enableAdmobInterstitial: function () {
// If we don't have admob support, don't try to configure anything
if (!admob)
return;
// Set up a listener for showing an interstitial once it arrives
document.addEventListener(admob.Event.onInterstitialReceive, function (message) {
admob.showInterstitial();
}, false);
// Request an interstitial to be sent
admob.cacheInterstitial(AdmobManager.admobCfg.extraParams);
}
}
在显示登录屏幕之前调用AdmobManager.initAdmob()
,然后在登录后调用AdmobManager.enableAdmobInterstitial()
。
当然,一旦您完成了测试,您将希望将isTesting
更改为false
相关文章:
- android phonegap jquery点击动态列表中的元素
- 如何在android phonegap中控制javascript
- 在Android Phonegap中加载附加模板时,JavaScript点击需要时间
- Android PhoneGap 1.7 调用 javascript 函数
- window.requestFileSystem 在 android phonegap 中失败
- Android phonegap access jarfile
- 在Android + PhoneGap中添加有关滚动的帖子
- 如何用javascript获取android phonegap中sdcard目录的完整路径
- html5视频标签在android phonegap中不起作用
- Android Phonegap应用程序中的Javascript到Java通信
- 如何在后台运行android phonegap应用程序(关闭应用程序后)
- Android/phonegap-点击响应时间慢
- 如何在android phonegap中最小化视频播放器的大小
- 如何使用android phonegap上传文件
- 将用java编写的活动添加到Android Phonegap应用程序中
- 如何在android phonegap中启用/添加滚动条
- 水平可滚动的图像在Android + PhoneGap + jQuery移动
- Android Phonegap:当AsyncTask完成时通知javascript
- 如何在android Phonegap的android SD卡上保存HTML5画布图像
- 在Android PhoneGap上长按按钮退出应用程序