我尝试了几个admob phonegap插件,但所有的phonegap插件都是用admob 1.0构建的.admob不再使用旧的sdk了。
是否有任何admob phonegap插件或admob cordova插件支持admob 2014 ios和android,新的谷歌服务sdk?
或任何有关如何创建插件的教程?
答案 0 :(得分:1)
也许这就是你所发现的。 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 或下载插件,然后安装本地位置 cordova插件添加c:\ phonegap-admob-plugin
如何使用admob phonegap插件?
1.在html5 app中创建并显示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. pow admob在cordova app中的插页式广告:
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.handle admob ad event
您可以处理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.展示具有绝对位置的adob旗帜 showBannerAbsolute(x,y,successCallback,failureCallback) 2.hide admob banner hideBanner() 3.测试插页式广告是否已成功加载 function isInterstitialReady(successCallback,failureCallback) 4.更多用法,参考index.js