最近刚刚开始研究facebook 的 instantgame,用官方提供的6.0版本的sdk,现在想展示广告,已经设置好了广告的id,但是确无法正常的展示广告
变量是这样定义的
@property
videoAdId:string="";
//@property
videoAd=null;
@property
picAdId:string="";
//@property
picAd=null;
id在编辑器里面填写
这个是预加载
LoadVideoAd()
{
FBInstant.getRewardedVideoAsync(
this.videoAdId, // Your Ad Placement Id
).then(function(rewarded) {
// Load the Ad asynchronously
this.videoAd = rewarded;
return this.videoAd.loadAsync();
}).then(function() {
console.log('Rewarded video preloaded')
Logger.instance.log('Rewarded video preloaded');
// Ad loaded
//this.showVideoButton.color=cc.Color.GREEN;
}).catch(function(err){
console.error('Rewarded video failed to preload: ' + err.message);
Logger.instance.log('Rewarded video failed to preload: ' + err.message);
});
}
这个是展示
ShowVideoAdCLick()
{
this.videoAd.showAsync()
.then(function() {
// Perform post-ad success operation
console.log(‘Rewarded video watched successfully’);
//video Ad watch
//this.showVideoButton.color=cc.Color.RED;
//再加载
this.LoadVideoAd();
})
.catch(function(e) {
console.error(e.message);
Logger.instance.log(e.message);
});
}
在iphone上 预加载的时候 显示预加载成功,但是却无法展示出来
在安卓手机上,预加载的时候直接失败了,显示错误“Client does not support the message:getrewardedvideoasync”
这里有人成功搞定了instantgame 的广告了吗?


