gpt4 book ai didi

ios - Admob:Interstitial 还没有准备好展示,为什么? ( swift )

转载 作者:行者123 更新时间:2023-11-28 12:21:57 25 4
gpt4 key购买 nike

我正在使用 AdMob 制作一个应用程序,问题是:该应用程序成功加载了广告,但在尝试展示它时,似乎广告尚未加载。我已按照 Google AdMob 上的指南进行操作...

这是我的 viewDidLoad() 中的内容

interstitial = GADInterstitial(adUnitID: "ca-app-pub-45863574112xxxxxxxxxx/xxxxxxx")
let request = GADRequest()
interstitial.load(request)

这就是我在点击按钮时调用它的地方:

if self.interstitial.isReady {
self.interstitial.present(fromRootViewController: self)
} else {
let alert = UIAlertController(title: "Couldn't load ad", message: "There was a problem while loading the ad... Still, thank you for wanting to support me :)", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Ok...", style: .cancel, handler: nil))
self.present(alert, animated: true)
}

嗯,我收到警报...你能告诉我为什么吗?

最佳答案

您可以通过实现委托(delegate)方法告诉自己原因:) https://developers.google.com/admob/ios/api/reference/Protocols/GADInterstitialDelegate

特别是 optional func interstitial(_ ad: GADInterstitial!, didFailToReceiveAdWithError error: Any!)

关于ios - Admob:Interstitial 还没有准备好展示,为什么? ( swift ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44528746/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com