Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

280
Visualizações
Cannot find type 'GADInterstitial' in scope?

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.

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Google have updated the SDK without telling anyone. Take a look at the new guide on Admob for adding an interstitial. Essentially GADInterstitial has changed to GADInterterstitialAd and you have to use a different Delegate too.

Thanks for that Google.

over 4 years ago · Santiago Trujillo Relatório

0

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")
      }
}         

}

over 4 years ago · Santiago Trujillo Relatório

0

Google Mobile Ads SDK 8.0 has a dramatic change of its API interfaces. Please refer to Google's official document for Interstitial. To make it complete, here is the reference to the legacy API prior to 8.0.

The main changes are the delegate and the Ad class:

old new
GADInterstitialDelegate GADFullScreenContentDelegate
GADInterstitial GADInterstitialAd

And instead of initializing the Ad in the legacy way:

interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/4411468910")
let request = GADRequest()
interstitial.load(request)

it's now initialized in the following way

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

And the new GADFullScreenContentDelegate methods:

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

/// Tells the delegate that the ad presented full screen content.
func adDidPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
  print("Ad did present full screen content.")
}

/// Tells the delegate that the ad dismissed full screen content.
func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
  print("Ad did dismiss full screen content.")
}

Note there is no longer the interstitialDidReceiveAd method. Instead you either start to present the Ad in the GADInterstitialAd.load() completion call back, or at a later stage to present the Ad if it is initialized:

if interstitial != nil {
  interstitial.present(fromRootViewController: self)
} else {
  print("Ad wasn't ready")
}
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda