I just upgraded Google Mobile Ads SDK to version 8.0, but I am getting this error:
Cannot find type 'GADInterstitial' in scope
I also added this code to AppDelegate:
GADMobileAds.sharedInstance().start(completionHandler: nil)
Google Mobile Ads SDK worked perfectly until I upgraded to version 8.0
Note: I also use Firebase Framework in my app.
Here this is the code of Admob Interstitial only copy and paste I just upgraded Google Mobile Ads SDK to version 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")
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With