Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

285
Views
¿No puede encontrar el tipo 'GADInterstitial' en el alcance?

Acabo de actualizar el SDK de Google Mobile Ads a la versión 8.0, pero recibo este error:

No se puede encontrar el tipo 'GADInterstitial' en el alcance

También agregué este código a AppDelegate:

 GADMobileAds.sharedInstance().start(completionHandler: nil)

El SDK de Google Mobile Ads funcionó perfectamente hasta que actualicé a la versión 8.0

Nota: También uso Firebase Framework en mi aplicación.

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Google ha actualizado el SDK sin decírselo a nadie. Echa un vistazo a la nueva guía de Admob para añadir un intersticial. Esencialmente, GADInterstitial ha cambiado a GADInterterstitialAd y también debe usar un Delegado diferente.

Gracias por eso Google.

over 4 years ago · Santiago Trujillo Report

0

Aquí está el código de Admob Interstitial, solo copiar y pegar. Acabo de actualizar el SDK de Google Mobile Ads a la versión 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 Report

0

Google Mobile Ads SDK 8.0 tiene un cambio dramático en sus interfaces API. Consulte el documento oficial de Google para anuncios intersticiales . Para completarlo, aquí está la referencia a la API heredada anterior a 8.0.

Los principales cambios son el delegado y la clase de anuncio:

viejo nuevo
GADInterstitialDelegate GADFullScreenContentDelegate
GADIntersticial GADIntersticialAd

Y en lugar de inicializar el anuncio de la forma heredada:

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

ahora se inicializa de la siguiente manera

 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 }

Y los nuevos métodos GADFullScreenContentDelegate:

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

Tenga en cuenta que ya no existe el método interstitialDidReceiveAd . En su lugar, comienza a presentar el anuncio en la devolución de llamada de finalización de GADInterstitialAd.load() , o en una etapa posterior para presentar el anuncio si se inicializa:

 if interstitial != nil { interstitial.present(fromRootViewController: self) } else { print("Ad wasn't ready") }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!