gpt4 book ai didi

ios - 在范围内找不到类型 'GADInterstitial'?

转载 作者:行者123 更新时间:2023-12-03 20:23:25 25 4
gpt4 key购买 nike

我刚刚将 Google Mobile Ads SDK 升级到 8.0 版,但出现了以下错误:

Cannot find type 'GADInterstitial' in scope


我还将这段代码添加到 AppDelegate:
GADMobileAds.sharedInstance().start(completionHandler: nil)
在我升级到 8.0 版之前,Google 移动广告 SDK 运行良好
注意:我还在我的应用程序中使用 Firebase 框架。

最佳答案

这是 Admob Interstitial 的代码,仅复制和粘贴
我刚刚将 Google 移动广告 SDK 升级到 8.0 版

import GoogleMobileAds

class ViewController: UIViewController,GADFullScreenContentDelegate{

private var interstitial: GADInterstitialAd?

override func viewDidLoad() {
super.viewDidLoad()

let request = GADRequest()
GADInterstitialAd.load(withAdUnitID:"ca-app-pub-3940256099942544/4411468910",request: request,
completionHandler: { [self] ad, error in
if let error = error {
return
}
interstitial = ad
interstitial?.fullScreenContentDelegate = self
}
)
}

func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {
print("Ad did fail to present full screen content.")
}

func adDidPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
print("Ad did present full screen content.")
}

func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
print("Ad did dismiss full screen content.")
}

@IBAction func AddAction(_ sender: UIButton) {
if interstitial != nil {
interstitial.present(fromRootViewController: self)
} else {
print("Ad wasn't ready")
}
}
}

关于ios - 在范围内找不到类型 'GADInterstitial'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66226165/

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