rewardedAd.load()不会第二次加载广告。在显示的第一个广告的加载,显示,回调方面一切正常,当我再次执行rewardedAd.load()以加载另一个广告时,什么也没有发生。没有错误,没有回调。然后明显地调用了rewardedAd.show()会引起admob /未就绪错误。
此问题出现在admob / firebase版本6.2.0和6.3.1中
if(environment == 'development'){
rewardedAd = RewardedAd.createForAdRequest(TestIds.REWARDED)
}
else if(environment == 'production'){
rewardedAd = RewardedAd.createForAdRequest(settings.adsUnitIds.ios.real)
}
// --
rewardedAd.onAdEvent((type, error, reward) => {
console.log('onAdEvent, type:', type, ', error:', error)
if(type === RewardedAdEventType.LOADED){
dispatch({ type: 'AD_LOADED' })
}
if(type == 'closed'){ // RewardedAdEventType.CLOSED isn't defined (probably bug), so just made it "closed", which works
console.log('ad closed, rewarded:', rewarded)
if(rewarded == true){
if(!doubleReward){
dispatch(rewardCoins(settings.coins.ad, 'watched-ad'))
}
else {
dispatch(rewardCoins(settings.coins.ad*2, 'watched-ad'))
}
rewarded = false
}
dispatch({ type: 'AD_CLOSED', rewarded: rewarded })
if(showEnded) showEnded()
setTimeout(() => { // Cannot reproduce bug where re-request of ad isn't available so adding this just in case
console.log('Start ad re-request')
console.log('Do we have rewardedAd variable? :', rewardedAd)
rewardedAd.load()
}, 200)
}
if(type === RewardedAdEventType.EARNED_REWARD){
console.log('earned reward!')
dispatch({ type: 'AD_REWARDED' })
rewarded = true
}
if(type === RewardedAdEventType.ERROR){
console.info('Some error with ad:', error)
}
})
rewardedAd.load()
显示后如何尝试自动加载?
rewardedAd.onAdEvent((type, error, reward) => {
...
if (!rewardedAd.loaded) rewardedAd.load()
})