我正在使用最新的广告播放服务(21.4.0),并看到以下行为(使用测试应用ID和测试广告ID进行测试):FullScreenContentCallback
的onAdDismissedFullScreenContent
函数从未被调用。
- 问题**
当我点击插播广告中的关闭按钮时,没有回调函数被调用......里面的所有其他函数(至少是非错误函数)都被成功调用。为什么?我错过了什么吗?我需要对广告被取消的事件做出React......
- 代码**
1.加载广告
InterstitialAd.load(
context,
adId,
AdRequest.Builder().build(),
createInterstitialAdListener()
)
1.等待广告加载到侦听器中
private fun createInterstitialAdListener(): InterstitialAdLoadCallback {
return object : InterstitialAdLoadCallback() {
override fun onAdLoaded(ad: InterstitialAd) {
super.onAdLoaded(ad)
L.d { "Interstitial ad loaded..." }
ad.fullScreenContentCallback = createFullScreenContentCallback("Interstitial")
interstitialAd = ad
this@AdsViewManager.onAdLoaded()
}
override fun onAdFailedToLoad(error: LoadAdError) {
super.onAdFailedToLoad(error)
onAdLoadingError(error.message)
}
}
}
private fun createFullScreenContentCallback(type: String): FullScreenContentCallback {
return object : FullScreenContentCallback() {
override fun onAdClicked() {
// works!
L.d { "[$type] FullScreen ad clicked" }
}
override fun onAdDismissedFullScreenContent() {
// never gets called!
L.d { "[$type] FullScreen ad dismissed" }
interstitialAd = null
rewardedAd = null
}
override fun onAdFailedToShowFullScreenContent(error: AdError) {
onAdLoadingError(error.message)
interstitialAd = null
rewardedAd = null
}
override fun onAdImpression() {
// works!
L.d { "[$type] FullScreen ad - IMPRESSION" }
}
override fun onAdShowedFullScreenContent() {
// works!
L.d { "[$type] FullScreen ad showed..." }
}
}
}
1.当广告准备好时显示它
fun show() {
if (interstitialAd == null) {
L.e { "Interstitial ad not ready" }
} else {
interstitialAd?.show(activity)
L.d { "Showing interstitial ad..." }
}
}
- 来自上述代码的日志**
Interstitial ad loaded...
Showing interstitial ad...
[Interstitial] FullScreen ad showed...
[Interstitial] FullScreen ad - IMPRESSION
// missing the close log... it never appears...
1条答案
按热度按时间toe950271#
在您的Activity中尝试这种方式
您的
loadAd
函数显示广告时,复制/粘贴以下内容...
它会像预期的那样工作。如果不工作,请告诉我