0
我有一个使用PhoneGap 3.4构建的Android应用程序。AdMob PhoneGap Plugin无法显示的广告
我运行该插件是:https://github.com/floatinghotpot/cordova-plugin-admob.git
安装说明:
A simplified method (tested on Cordova 3.4.0)
1. Install the Google Play Services plugin:
```cordova plugin add https://github.com/MobileChromeApps/google-play-services.git```
2. Install _this_ plugin:
```cordova plugin add https://github.com/floatinghotpot/cordova-plugin-admob.git```
用于显示广告的方向是:
##Using the Plugin:
There are 3 calls needed to get AdMob Ads:
1. `createBannerView`
Takes in a object containing a publisherId and adSize, as well as success
and failure callbacks. An example call is provided below:
window.plugins.AdMob.createBannerView(
{
'publisherId': 'INSERT_YOUR_PUBLISHER_ID_HERE',
'adSize': window.plugins.AdMob.AD_SIZE.BANNER
},
successCallback,
failureCallback
);
2. `requestAd`
Takes in an object containing an optional testing flag, and an optional
list of extras. This method should only be invoked once createBannerView
has invoked successCallback. An example call is provided below:
window.plugins.AdMob.requestAd(
{
'isTesting': false,
'extras': {
'color_bg': 'AAAAFF',
'color_bg_top': 'FFFFFF',
'color_border': 'FFFFFF',
'color_link': '000080',
'color_text': '808080',
'color_url': '008000'
},
},
successCallback,
failureCallback
);
3. `showAd`
Show or hide the Ad.
此方法只被调用一次createBannerView调用了successCallback。
一个示例呼叫设置下面: window.plugins.AdMob.showAd( 真, successCallback, failureCallback ); 这里是我的尝试:
function onLoad(){
document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {
if(window.plugins && window.plugins.AdMob) {
var admob_android_key = 'ca-app-pub-xxxxxxxxxxxxxxxxxxxxxxx';
var adId = (navigator.userAgent.indexOf('Android') >=0) ? admob_android_key : admob_ios_key;
var am = window.plugins.Admob;
am.createBannerView(
{
'publisherId': adId,
'adSize': am.AD_SIZE.BANNER,
'bannerAtTop': false
},
function() {
am.requestAd(
{ 'isTesting':false },
function(){
am.showAd(true);
},
function(){ alert('failed to request ad'); }
);
},
function(){ alert('failed to create banner view'); }
);
} else {
alert('AdMob plugin not available/ready.');
}
}
任何想法,我这个问题呢?先谢谢你。
你从cordova plugin自述中复制粘贴了几件东西,并希望有人在工作示例中将它们结合起来使用? –
好的,我更新了这个例子。但没有任何反应。我认为这个语法是正确的,Readme说这应该起作用。 – Bacon2305