我正在使用AdMob制作一个应用程序,问题是:该应用程序成功加载了广告,但是在尝试呈现广告时,广告似乎尚未加载。我已经按照谷歌AdMob上的指南...
这是我的观点DidLoad((
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)
}
好吧,我收到警报...你能告诉我为什么吗?
你可以告诉自己为什么:)通过实现委托方法 https://developers.google.com/admob/ios/api/reference/Protocols/GADInterstitialDelegate
具体optional func interstitial(_ ad: GADInterstitial!, didFailToReceiveAdWithError error: Any!)