也许这就是您所发现的。 admob phonegap插件支持admob 2,admob Google Service SDK。
admob phonegap(cordova)插件
admob phonegap(cordova)插件,支持ios和android
基于phonegap 3.4或cordova 3.5构建
主页:https://github.com/admob-google/admob-phonegap
如何安装Google admob phonegap插件?
使用cordova命令
cordova插件添加https://github.com/admob-google/admob-phonegap
或下载插件,然后在本地安装
科尔多瓦插件添加c:\ phonegap-admob-plugin
如何使用admob phonegap插件?
1.在html5应用中创建并显示admob横幅广告
function showBanner() {
var successCreateBannerView = function () {
admobAd.showBanner(admobAd.AD_POSITION.BOTTOM_CENTER);//show banner at the bottom center
};
var errorCreateBannerView = function (message) {
console.log("create ad fail " + message);
};
admobAd.initBanner("your admob id here", admobAd.AD_SIZE.BANNER.width, admobAd.AD_SIZE.BANNER.height, successCreateBannerView, errorCreateBannerView);//create admob banner
}
showBanner();
2.在cordova应用中显示admob Interstitial:
function onInterstitialReceive(message) {
admobAd.showInterstitial();//show Interstitial after receive or after game over
}
function successCreateInterstitial() {
admobAd.cacheInterstitial();// load admob Interstitial
}
document.addEventListener('onAdmobInterstitialReceive', this.onInterstitialReceive, false);//handler admob event
admobAd.initInterstitial("your admob id here", successCreateInterstitial);//create Interstitial ad
3.处理admob广告事件
您可以处理admob的所有本地事件,如onInterstitialReceive
所有事件类型都在AdEvent中
document.addEventListener('onAdmobBannerDismiss', this.onAdmobEvent, false);
document.addEventListener('onAdmobBannerFailedReceive', this.onAdmobEvent, false);
document.addEventListener('onAdmobBannerLeaveApplication', this.onAdmobEvent, false);
document.addEventListener('onAdmobBannerPresent', this.onAdmobEvent, false);
document.addEventListener('onAdmobBannerReceive', this.onAdmobEvent, false);
document.addEventListener('onAdmobInterstitialDismiss', this.onAdmobEvent, false);
document.addEventListener('onAdmobInterstitialFailedReceive', this.onAdmobEvent, false);
document.addEventListener('onAdmobInterstitialLeaveApplication', this.onAdmobEvent, false);
document.addEventListener('onAdmobInterstitialPresent', this.onAdmobEvent, false);
document.addEventListener('onAdmobInterstitialReceive', this.onAdmobEvent, false);
更多功能
1.显示带有绝对位置的admob横幅
showBannerAbsolute(x,y,successCallback,failureCallback)
2.隐藏admob横幅
hideBanner()
3.测试插页式广告是否加载成功
函数isInterstitialReady(successCallback,failureCallback)
4.更多用法请参考index.js