Migrazione dell'SDK

Questa pagina illustra le migrazioni per le versioni attuali e precedenti dell'SDK Google Mobile Ads per iOS. La versione 12.0.0 dovrebbe essere rilasciata a febbraio 2025.

Esegui la migrazione dalla versione dell'SDK 11 alla 12

Eseguire l'upgrade a Xcode 16.0

La versione minima di Xcode supportata è stata aumentata a 16.0.

Supporto dei nomi Swift

La versione 12.0.0 include modifiche per rispettare le convenzioni di denominazione riportate nelle linee guida per la progettazione di API di Swift. Queste modifiche riguardano solo Swift. Non sono state apportate modifiche ai nomi delle API Objective-C.

Modifiche al prefisso del corso

Sono state apportate le seguenti modifiche ai prefissi delle classi:

  • È stato rimosso il prefisso GAD dai nomi di tutti i tipi.
  • Il prefisso GAM è stato rinominato in AdManager.
  • Il prefisso GADM è stato rinominato in Mediation.

Risolvere gli errori

Il modo migliore per risolvere gli errori derivanti da queste modifiche è apportare una correzione con lo strumento Fix-It.

Risolvere i conflitti di denominazione

Per risolvere i conflitti di denominazione, utilizza lo spazio dei nomi fornito dal modulo. Ad esempio, GADRequest ora si chiama Request. Di seguito sono riportati alcuni esempi di spazi dei nomi della classe Request dell'SDK Google Mobile Ads:

import GoogleMobileAds
...
var request: GoogleMobileAds.Request?

Elenco dettagliato delle modifiche a Swift

Le tabelle riportate di seguito elencano le modifiche apportate alle API Swift:

Versione 11 Versione 12
GADAdapterInitializationState AdapterInitializationState
GADAdChoicesPosition AdChoicesPosition
GADAdChoicesView AdChoicesView
GADAdFormat AdFormat
GADAdLoader AdLoader
GADAdLoaderAdType AdLoaderAdType
GADAdLoaderDelegate AdLoaderDelegate
GADAdMetadataDelegate AdMetadataDelegate
GADAdMetadataProvider AdMetadataProvider
GADAdNetworkExtras AdNetworkExtras
GADAdNetworkResponseInfo AdNetworkResponseInfo
GADAdReward AdReward
GADAdSize AdSize
GADAdSizeDelegate AdSizeDelegate
GADAdValue AdValue
GADAdValuePrecision AdValuePrecision
GADAppEventDelegate AppEventDelegate
GADAppOpenAd AppOpenAd
GADAppOpenSignalRequest AppOpenSignalRequest
GADAudioVideoManager AudioVideoManager
GADAudioVideoManagerDelegate AudioVideoManagerDelegate
GADBannerSignalRequest BannerSignalRequest
GADBannerView BannerView
GADBannerViewDelegate BannerViewDelegate
GADCustomEventExtras CustomEventExtras
GADCustomEventRequest CustomEventRequest
GADCustomNativeAd CustomNativeAd
GADCustomNativeAdLoaderDelegate CustomNativeAdLoaderDelegate
GADCustomNativeAdDelegate CustomNativeAdDelegate
GADDebugOptionsViewControllerDelegate DebugOptionsViewControllerDelegate
GADDebugOptionsViewController DebugOptionsViewController
GADDisplayAdMeasurement DisplayAdMeasurement
GADExtras Extras
GADFullScreenPresentingAd FullScreenPresentingAd
GADFullScreenContentDelegate FullScreenContentDelegate
GADAdapterStatus AdapterStatus
GADInitializationStatus InitializationStatus
GADInterstitialAd InterstitialAd
GADInterstitialSignalRequest InterstitialSignalRequest
GADMediaAspectRatio MediaAspectRatio
GADMediaContent MediaContent
GADMediaView MediaView
GADMobileAds MobileAds
GADMultipleAdsAdLoaderOptions MultipleAdsAdLoaderOptions
GADMuteThisAdReason MuteThisAdReason
GADNativeAd NativeAd
GADNativeAdLoaderDelegate NativeAdLoaderDelegate
GADNativeAdView NativeAdView
GADNativeAdCustomClickGestureOptions NativeAdCustomClickGestureOptions
GADNativeAdDelegate NativeAdDelegate
GADNativeAdImage NativeAdImage
GADNativeAdImageAdLoaderOptions NativeAdImageAdLoaderOptions
GADNativeAdInlineBehavior NativeAdInlineBehavior
GADNativeAdInlineBehaviorOptions NativeAdInlineBehaviorOptions
GADNativeAdMediaAdLoaderOptions NativeAdMediaAdLoaderOptions
GADNativeAdUnconfirmedClickDelegate NativeAdUnconfirmedClickDelegate
GADNativeAdViewAdOptions NativeAdViewAdOptions
GADNativeMuteThisAdLoaderOptions NativeMuteThisAdLoaderOptions
GADNativeSignalRequest NativeSignalRequest
GADPresentationError PresentationError
GADPublisherPrivacyPersonalizationState PublisherPrivacyPersonalizationState
GADQueryInfo QueryInfo
GADRequest Request
GADRequestError RequestError
GADRequestConfiguration RequestConfiguration
GADResponseInfo ResponseInfo
GADRewardedAd RewardedAd
GADRewardedSignalRequest RewardedSignalRequest
GADRewardedInterstitialAd RewardedInterstitialAd
GADRewardedInterstitialSignalRequest RewardedInterstitialSignalRequest
GADSearchBannerView SearchBannerView
GADServerSideVerificationOptions ServerSideVerificationOptions
GADSignal Signal
GADSignalRequest SignalRequest
GADVersionNumber VersionNumber
GADVideoController VideoController
GADVideoControllerDelegate VideoControllerDelegate
Ad Manager
GAMBannerAdLoaderDelegate AdManagerBannerAdLoaderDelegate
GAMBannerView AdManagerBannerView
GAMBannerViewOptions AdManagerBannerViewOptions
GAMInterstitialAd AdManagerInterstitialAd
GAMRequest AdManagerRequest
Mediazione
GADMAdNetworkAdapter MediationAdNetworkAdapter
GADMAdNetworkConnector MediationAdNetworkConnector
GADMBannerAnimationType MediationBannerAnimationType
GADMediatedUnifiedNativeAd MediationUnifiedNativeAd
GADMediatedUnifiedNativeAdNotificationSource MediationUnifiedNativeAdNotificationSource
GADMediationAd MediationAd
GADMediationAdConfiguration MediationAdConfiguration
GADMediationAdEventDelegate MediationAdEventDelegate
GADMediationAdRequest MediationAdRequest
GADMediationAdapter MediationAdapter
GADMediationAppOpenAd MediationAppOpenAd
GADMediationAppOpenAdEventDelegate MediationAppOpenAdEventDelegate
GADMediationBannerAd MediationBannerAd
GADMediationBannerAdConfiguration MediationBannerAdConfiguration
GADMediationBannerAdEventDelegate MediationBannerAdEventDelegate
GADMediationCredentials MediationCredentials
GADMediationInterstitialAd MediationInterstitialAd
GADMediationInterstitialAdConfiguration MediationInterstitialAdConfiguration
GADMediationInterstitialAdEventDelegate MediationInterstitialAdEventDelegate
GADMediationNativeAd MediationNativeAd
GADMediationNativeAdConfiguration MediationNativeAdConfiguration
GADMediationNativeAdEventDelegate MediationNativeAdEventDelegate
GADMediationRewardedAd MediationRewardedAd
GADMediationRewardedAdConfiguration MediationRewardedAdConfiguration
GADMediationRewardedAdEventDelegate MediationRewardedAdEventDelegate
GADMediationServerConfiguration MediationServerConfiguration
Offerta in tempo reale
GADRTBAdapter RTBAdapter
GADRTBMediationSignalsConfiguration RTBMediationSignalsConfiguration
GADRTBRequestParameters RTBRequestParameters

Costanti

Versione 11 Versione 12
GADAdLoaderAdType.gamBanner AdLoaderAdType.adManagerBanner
GADAdSizeBanner AdSizeBanner
GADAdSizeFluid AdSizeFluid
GADAdSizeFullBanner AdSizeFullBanner
GADAdSizeInvalid AdSizeInvalid
GADAdSizeLargeBanner AdSizeLargeBanner
GADAdSizeLeaderboard AdSizeLeaderboard
GADAdSizeMediumRectangle AdSizeMediumRectangle
GADAdSizeSkyscraper AdSizeSkyscraper
GoogleMobileAdsVersionString GoogleMobileAdsVersion

Proprietà

Tipo Versione 11 Versione 12
GADAdLoader loading isLoading
GADAudioVideoManager audioSessionApplicationManaged isAudioSessionApplicationManaged
GADBannerView autoloadEnabled isAutoloadEnabled
GADMobileAds sharedInstance shared
applicationMuted isApplicationMuted
GADMuteThisAdReason reasonDescription reason
GADNativeAd customMuteThisAdAvailable isCustomMuteThisAdAvailable
GADNativeAdCustomClickGestureOptions tapsAllowed areTapsAllowed
GADNativeAdImageAdLoaderOptions imageLoadingDisabled isImageLoadingDisabled
GADNativeMuteThisAdLoaderOptions customMuteThisAdRequested isCustomMuteThisAdRequested
GADNativeSignalRequest imageLoadingDisabled isImageLoadingDisabled
customMuteThisAdRequested isCustomMuteThisAdRequested
GADRequest neighboringContentURLStrings neighboringContentURLs
GADResponseInfo extrasDictionary extras
GADServerSideVerificationOptions customRewardString customRewardText
GADSignal signalString signal
GADSignalRequest neighboringContentURLStrings neighboringContentURLs
GADVideoController customControlsRequested areCustomControlsRequested
clickToExpandEnabled isClickToExpandEnabled
GADVideoOptions startMuted shouldStartMuted
customControlsRequested areCustomControlsRequested
clickToExpandRequested isClickToExpandRequested

Funzioni

Tipo Versione 11 Versione 12
GADAdSize GADPortraitInlineAdaptiveBannerAdSizeWithWidth(_:) portraitInlineAdaptiveBanner(width:)
GADLandscapeInlineAdaptiveBannerAdSizeWithWidth(_:) landscapeInlineAdaptiveBanner(width:)
GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(_:) currentOrientationInlineAdaptiveBanner(width:)
GADInlineAdaptiveBannerAdSizeWithWidthAndMaxHeight(_:, _:) inlineAdaptiveBanner(width:maxHeight:)
GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth(_:) portraitAnchoredAdaptiveBanner(width:)
GADLandscapeAnchoredAdaptiveBannerAdSizeWithWidth(_:) landscapeAnchoredAdaptiveBanner(width:)
GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(_:) currentOrientationAnchoredAdaptiveBanner(width:)
GADAdSizeFromCGSize(_:) adSizeFor(cgSize:)
GADAdSizeFullWidthPortraitWithHeight(_:) fullWidthPortrait(height:)
GADAdSizeFullWidthLandscapeWithHeight(_:) fullWidthLandscape(height:)
GADAdSizeEqualToSize(_:, _:) isAdSizeEqualToSize(size1:size2:)
IsGADAdSizeValid(_:) isAdSizeValid(size:)
GADAdSizeIsFluid(_:) isAdSizeFluid(size:)
CGSizeFromGADAdSize(_:) cgSize(for:)
NSStringFromGADAdSize(_:) string(for:)
NSValueFromGADAdSize(_:) nsValue(for:)
GADAdSizeFromNSValue(_:) adSizeFor(nsValue:)
GADClosestValidSizeForAdSizes(_:_:) closestValidSizeForAdSizes(original:possibleAdSizes:)
GADAppEventDelegate adView(_:didReceiveAppEvent:withInfo:) adView(_:didReceiveAppEvent:with:)
interstitialAd(_:didReceiveAppEvent:withInfo:) adView(_:didReceiveAppEvent:with:)
GADAppOpenAd load(withAdResponseString:) load(with:)
load(withAdUnitID:request:completionHandler:) load(with:request:completionHandler:)
canPresent(fromRootViewController:) canPresent(from:)
present(fromRootViewController:) present(from:)
GADBannerView load(withAdResponseString:) load(with:)
GADInterstitial load(withAdResponseString:) load(with:)
load(withAdUnitID:request:completionHandler:) load(with:request:completionHandler:)
canPresent(fromRootViewController:) canPresent(from:)
present(fromRootViewController:) present(from:)
GADRewardedAd load(withAdResponseString:) load(with:)
load(withAdUnitID:request:completionHandler:) load(with:request:completionHandler:)
canPresent(fromRootViewController:) canPresent(from:)
present(fromRootViewController:userDidEarnRewardHandler:) present(from:userDidEarnRewardHandler:)
GADRewardedInterstitialAd load(withAdResponseString:) load(with:)
load(withAdUnitID:request:completionHandler:) load(with:request:completionHandler:)
canPresent(fromRootViewController:) canPresent(from:)
present(fromRootViewController:userDidEarnRewardHandler:) present(from:userDidEarnRewardHandler:)
GADVersionNumber GADGetStringFromVersionNumber(_ version: GADVersionNumber) string(for:)
Mediazione
GADMAdNetworkAdapter getBannerWith(_:) getBanner(with:)
presentInterstitial(fromRootViewController:) presentInterstitial(from:)
getNativeAd(withAdTypes:options:) getNativeAd(with:options:)
GADMediatedUnifiedNativeAd didRecordClickOnAsset(withName:view:viewController:) didRecordClickOnAsset(with:view:viewController:)
GADMediationAdapter setUpWith(_:completionHandler:) setUp(with:completionHandler:)
GADMediationAdSize present(fromRootViewController:) present(from:)
GADMediationAppOpenAd present(fromRootViewController:) present(from:)
GADMediationInterstitialAd present(fromRootViewController:) present(from:)
GADMediationRewardedAd present(fromRootViewController:) present(from:)
GAMInterstitialAd load(withAdManagerAdUnitID:request:completionHandler:) load(with:request:completionHandler:)

Modifiche all'API per il controllo dello stato di disattivazione dell'audio dei video

La proprietà isMuted e il metodo setMute: su GADVideoController vengono sostituiti con una proprietà muted.

Modifiche agli annunci adattivi in linea

Per ottimizzare l'utilizzo dello spazio, inizialmente gli annunci adattivi in linea non occupano spazio nel frame. La chiamata a CGSizeFromGADAdSize(_:) con una dimensione dell'annuncio adattabile in linea ora restituisce un'altezza di 0 finché l'SDK Google Mobile Ads non restituisce un annuncio.

Annunci associati alla ricerca personalizzata rimossi

I seguenti corsi vengono rimossi senza sostituzione:

  • GADDynamicHeightSearchBannerView
  • GADDynamicHeightSearchRequest
  • GADSearchBannerView

Modifiche ai codici di errore

I seguenti codici di errore sono stati modificati:

Classe Note
GADErrorMediationNoFill Ora gli errori vengono restituiti come GADErrorNoFill.
GADErrorReceivedInvalidResponse È stato sostituito con GADErrorReceivedInvalidAdString.

GADSimulatorID rimosso

GADSimulatorID rimosso. Per impostazione predefinita, i simulatori sono già in modalità di test.

Modifiche al targeting personalizzato

Il dizionario customTargeting su GADRequest ora utilizza Any anziché String come tipo di valore. In questo modo puoi passare valori numerici all'API.

Modifiche ai parametri extra

Eseguire la migrazione dalla versione 10 alla versione 11

Destinazione di deployment minima

La destinazione di deployment minima è stata aumentata a iOS 12.

Versione Xcode minima

La versione minima di Xcode supportata è stata aumentata a 15.1.

La pubblicazione degli annunci su iOS 12 viene interrotta

L'SDK Google Mobile Ads 11.0.0 pubblica annunci solo su dispositivi con iOS 13 o versioni successive.

È stata rimossa la dipendenza da GoogleAppMeasurement

Nella versione 11.0.0, la dipendenza da GoogleAppMeasurement è stata rimuovere. Questa dipendenza che ha supportato il pulsante di attivazione/disattivazione delle metriche utente in AdMob verrà interrotta all'inizio del 2024. Per continuare a raccogliere le metriche utente in AdMob, collega l'app AdMob a Firebase e integra l'SDK Google Analytics for Firebase nella tua app.

Modifiche alla presentazione degli annunci a schermo intero

Le seguenti modifiche interessano i vari formati degli annunci:

  • Apertura app
  • Interstitial
  • Con premio
  • Interstitial con premio

Il parametro del controller della visualizzazione in -canPresentFromRootViewController:error: e -presentFromRootViewController: è nullable. Se viene passato nil, l'annuncio viene presentato dal UIViewController più alto nella gerarchia dei UIViewController.

Metodi rimossi

I seguenti metodi sono stati rimossi.

Tipo v11.0.0 Metodo Note
GADAppOpenAd load(withAdUnitID adUnitID: String, request: GADRequest?, orientation: UIInterfaceOrientation) Utilizza load(withAdUnitID adUnitID: String, request: GADRequest?).
GADMediationBannerAdEventDelegate willBackgroundApplication() Nessuna sostituzione.
GADMediationInterstitialAdEventDelegate willBackgroundApplication() Nessuna sostituzione.
GADMediationNativeAdEventDelegate willBackgroundApplication() Nessuna sostituzione.
GADMediationRewardedAdEventDelegate didRewardUser(with reward: GADAdReward) Utilizza didRewardUser().
GADMediatedUnifiedNativeAdNotificationSource mediatedNativeAdWillLeaveApplication(_ mediatedNativeAd: GADMediatedUnifiedNativeAd) Nessuna sostituzione.
GADRequestConfiguration setSameAppKeyEnabled(_ enabled: Bool) Utilizza invece setPublisherFirstPartyIDEnabled(_ enabled: Bool).
tagForUnderAge(ofConsent underAgeOfConsent: Bool) Utilizza invece la proprietà tagForUnderAgeOfConsent.
tag(forChildDirectedTreatment childDirectedTreatment: Bool) Utilizza invece la proprietà tagForChildDirectedTreatment.

Proprietà rimosse

Le seguenti proprietà vengono rimosse.

Classe v11.0.0 Proprietà Note
GADMediationAdConfiguration hasUserLocation Nessuna sostituzione.
userLatitude
userLongitude
userLocationAccuracyInMeters
childDirectedTreatment Utilizza GADMobileAds.sharedInstance.requestConfiguration.tagForChildDirectedTreatment.
GADResponseInfo adNetworkClassName Utilizza invece adNetworkClassName da loadedAdNetworkResponseInfo.

GADAdFormatUnknown rimosso

L'elemento GADAdFormatUnknown è stato rimosso senza sostituzione.

Modifiche alla versione dell'SDK di registrazione

La versione 11.0.0 rimuove sdkVersion. Per registrare la versione dell'SDK Google Mobile Ads, utilizza versionNumber.

Versione 10.0.0

GADMobileAds.sharedInstance().sdkVersion

Versione 11.0.0

GADGetStringFromVersionNumber(GADMobileAds.sharedInstance().versionNumber)

Modifiche alla gestione degli errori di GADAdLoader

A partire dalla versione 11.0.0, GADAdLoader non effettua una richiesta di annuncio se il suo delegate non è conforme al protocollo del delegato dei tipi di annunci richiesti. In precedenza, il controllo non andava a buon fine dopo l'invio della richiesta di annuncio.

Modifiche al comportamento dei test

Consulta la tabella che mostra le condizioni aggiornate per quando le proprietà riportate di seguito restituiscono true.

Classe Proprietà
GADMediationAdConfiguration isTestRequest
GADCustomEventRequest isTesting
v10.0.0 v11.0.0
  • Il dispositivo è dichiarato esplicitamente come dispositivo di test in testDeviceIdentifiers.
  • Il dispositivo è dichiarato esplicitamente come dispositivo di test in testDeviceIdentifiers.
  • Il dispositivo è un simulatore.
  • Il dispositivo è dichiarato esplicitamente come dispositivo di test nell'interfaccia utente di AdMob.

Eseguire la migrazione dalla versione 9 alla versione 10

Interruzione della pubblicazione degli annunci su iOS 11

La versione 10.0.0 dell'SDK Google Mobile Ads pubblica annunci solo su dispositivi con iOS 12 o versioni successive.

L'upgrade alla versione 10.0.0 dell'SDK Google Mobile Ads non causerà errori nell'app sui dispositivi iOS 11 e iOS 10, ma su questi dispositivi non verranno pubblicati annunci.

La compilazione con codice bit non è più supportata

Per integrare l'SDK Google Mobile Ads, ora è necessario disattivare il codice bit nelle app mobile.

Tipi rimossi

Tipo Note
GADGender Nessuna sostituzione.
GADMRewardBasedVideoAdNetworkAdapterProtocol Tutti gli adattatori di mediazione con premio elencati su Choose Networks hanno smesso di utilizzare questi protocolli da oltre un anno. Utilizza GADMediationAdapter per la mediazione e gli eventi personalizzati.
GADMRewardBasedVideoAdNetworkConnectorProtocol

Proprietà rimosse

Le seguenti proprietà vengono rimosse senza alcuna sostituzione.

Classe v10.0.0 Proprietà
GADMediationAdRequest userBirthday
userGender
userHasLocation
userLatitude
userLongitude
userLocationAccuracyInMeters
userLocationDescription
GADCustomEventRequest userHasLocation
userLatitude
userLongitude
userLocationAccuracyInMeters
userLocationDescription

Eseguire la migrazione dalla versione 8 alla versione 9

La pubblicazione degli annunci su iOS 10 viene interrotta

La versione minima di iOS supportata dalla versione 9.0.0 dell'SDK Google Mobile Ads è iOS 11.

L'upgrade all'SDK Google Mobile Ads 9.0.0 non causerà errori nella tua app sui dispositivi iOS 10, ma su questi dispositivi non verranno pubblicati annunci.

Applicazione più rigorosa dei controlli della barra di stato

A partire dalla versione 9.0.0, quando presenti annunci in formato a schermo intero, la tua app deve assicurarsi che gli annunci siano in grado di controllare la presentazione della barra di stato. Se non lo fai, nei log viene visualizzato un messaggio di errore.

A seconda del layout specifico dei view controller nella tua app, potresti non dover apportare modifiche per assicurarti che ciò accada. Valuta se devi impostare la proprietà childViewControllerForStatusBarHidden su rootViewController dell'annuncio.

Rinomina adDidPresentFullScreenContent: in adWillPresentFullScreenContent:

Non è prevista alcuna modifica del comportamento. Il metodo del delegato viene invocato poco prima che l'annuncio venga visualizzato, pertanto il nuovo nome del metodo riflette meglio la sua funzionalità.

Rimuovere l'API di impostazione della posizione in GADRequest

- (void)setLocationWithLatitude:longitude:accuracy: è stato eliminato da GADRequest poiché i dati sulla posizione non vengono utilizzati da Google per scegliere gli annunci target. Utilizza le API di terze parti per fornire le informazioni alle reti pubblicitarie di terze parti, se necessario.

Ritiro delle interfacce di eventi personalizzati

Gli eventi personalizzati consentono ai publisher che utilizzano Mediazione AdMob di aggiungere la mediazione con struttura a cascata per una rete pubblicitaria che non è una delle reti pubblicitarie supportate.

Tutti i protocolli di eventi personalizzati sono stati ritirati. Utilizza invece i protocolli GADMediationAdapter e GADMediationAdEventDelegate esistenti per ottenere le stesse funzionalità. Questa modifica migliora la chiarezza e consente di creare eventi personalizzati per gli annunci con premio e gli annunci interscroller che non erano disponibili in precedenza.

API

La tabella seguente elenca le API di adattatore della mediazione corrispondenti alle API di eventi personalizzati che devono essere utilizzate a partire dalla versione 9.0.0.

v8 v9
GADCustomEventBanner
GADCustomEventInterstitial
GADCustomEventNativeAd
GADMediationAdapter GADMediationBannerAd
GADMediationInterstitialAd
GADMediationInterscrollerAd
GADMediationRewardedAd
GADMediationNativeAd
delegate Il delegato viene restituito dal gestore del completamento del caricamento di ogni funzione di caricamento della classe GADMediationAdapter
-init -init
-requestBannerAd:parameter:label:request: -loadBannerForAdConfiguration:completionHandler:
-requestInterstitialAdWithParameter:label:request: -loadInterstitialForAdConfiguration:completionHandler:
-requestNativeAdWithParameter:request:adTypes:options:rootViewController: -loadNativeAdForAdConfiguration:completionHandler:
N/D -loadInterscrollerAdForAdConfiguration:completionHandler:
N/D -loadRewardedAdForAdConfiguration:completionHandler:
-presentFromRootViewController: -presentFromViewController:
-handlesUserClicks -handlesUserClicks
-handlesUserImpressions -handlesUserImpressions

Metodi delegati

Nella tabella seguente sono elencati i metodi del delegato per gli eventi correlati agli annunci della mediazione corrispondenti ai metodi del delegato per gli eventi personalizzati che devono essere utilizzati a partire dalla versione 9.0.0.

v8 v9
GADCustomEventBannerDelegate
GADCustomEventInterstitialDelegate
GADCustomEventNativeAdDelegate
GADMediationAdEventDelegate GADMediationAd
-customEventBanner:didReceiveAd:
-customEventInterstitialDidReceiveAd:
Lo stato di caricamento dell'annuncio è incluso nel gestore del completamento del caricamento di ogni funzione di caricamento della classe GADMediationAdapter
-customEventBanner:didFailAd:
-customEventInterstitial:didFailAd:
-customEventBannerWasClicked:
-customEventInterstitialWasClicked:
-reportClick
-customEventBannerWillPresentModal:
-customEventInterstitialWillPresentModal:
-willPresentFullScreenView
-customEventBannerWillDismissModal:
-customEventInterstitialWillDismissModal:
-willDismissFullScreenView
-customEventBannerDidDismissModal:
-customEventInterstitialDidDismissModal:
-didDismissFullScreenView
-customEventBannerWillLeaveApplication:
-customEventInterstitialWillLeaveApplication:
-willBackgroundApplication
viewControllerForPresentingModalView -[GADMediationBannerAd view]

Altri metodi e costanti rimossi/sostituiri

Modifiche a metodo, costante o proprietà
kGAD- Costanti con prefisso Rimosso. Utilizza costanti con prefisso GAD-.
GADAdNetworkResponseInfo credentials sono stati rimossi. Utilizza invece adUnitMapping.
GADCustomNativeAd mediaView in GADCustomNativeAd è deprecato. Utilizza invece mediaContent.
API di acquisto in-app in GoogleMobileAds Le API inAppPurchase in GoogleMobileAds sono state rimosse.

Eseguire la migrazione dalla versione 7 alla versione 8

La versione 8.0.0 dell'SDK Google Mobile Ads presenta alcuni cambiamenti importanti oltre a modifiche di nomi e rimozioni di alcune API.

Aggiornamenti dell'API per i formati a schermo intero

A partire dalla versione 8.0.0, gli annunci interstitial e con premio condividono uno stile generico degli annunci a schermo intero per una maggiore coerenza. Queste nuove API per gli annunci a schermo intero presentano due importanti differenze rispetto alle API per gli annunci a schermo intero della versione 7:

  1. Metodo di classe statico load.

    L'approccio precedente per caricare/mostrare un annuncio a schermo intero è il seguente:

    1. Crea un'istanza dell'oggetto annuncio e tieni un riferimento.
    2. Assegna un delegato che gestisce il caricamento e mostra i callback.
    3. Carica un annuncio.
    4. Controlla se l'annuncio è stato caricato utilizzando isReady.
    5. Mostra l'annuncio.

    Nella versione 8, l'approccio cambia leggermente. I callback di caricamento non fanno più parte di un delegato. ma vengono passati al metodo load come gestore di completamento:

    1. Chiama un metodo di caricamento statico nella classe dell'annuncio e fornisci un gestore del completamento del caricamento.
    2. Nel callback di completamento del caricamento, mantieni un riferimento all'annuncio caricato che viene restituito.
    3. Assegna un delegato che gestisce i callback di visualizzazione.
    4. Mostra l'annuncio.

    Il nuovo approccio offre i seguenti vantaggi:

    • Non avrai mai un riferimento a un annuncio non caricato.
    • Non è necessario mantenere un oggetto annuncio durante il caricamento.
  2. Eventi annuncio coerenti.

    Tipo di evento API esistente API v8
    Eventi di caricamento GADInterstitialDelegate o GADRewardedAdDelegate GADInterstitialAdLoadCompletionHandler o GADRewardedAdLoadCompletionHandler
    Eventi di presentazione GADFullScreenContentDelegate

    In precedenza, per ascoltare gli eventi correlati agli annunci, dovevi registrare una classe che implementa il protocollo GADInterstitialDelegate nella proprietà delegata di un annuncio in primo piano o una classe che implementa il protocollo GADRewardedAdDelegate nella proprietà delegata di un annuncio con premio, a seconda del formato utilizzato. Lo stesso delegato aveva metodi relativi sia al ciclo di vita di caricamento sia di presentazione di un annuncio.

    Con la versione 8, gli eventi di caricamento e di presentazione sono separati. Ora puoi registrare un GADFullScreenContentDelegate in qualsiasi momento prima di mostrare un annuncio, anziché dover impostare un singolo delegato prima di caricarlo. Gli eventi di caricamento degli annunci, specifici per ogni formato, passano a un singolo gestore del completamento del caricamento passato nel metodo di caricamento.

Interstitial

Carica annuncio

Gli snippet di codice riportati di seguito mostrano come caricare un annuncio interstitial e ascoltare gli eventi quando il caricamento dell'annuncio va a buon fine o non va a buon fine.

Versione 7

Swift

import GoogleMobileAds
import UIKit

class ViewController: UIViewController, GADInterstitialDelegate {

  var interstitial: GADInterstitial!

  override func viewDidLoad() {
    super.viewDidLoad()
    interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/4411468910")
    interstitial.delegate = self
    let request = GADRequest()
    interstitial.load(request)
  }

  /// Tells the delegate an ad request succeeded.
  func interstitialDidReceiveAd(_ ad: GADInterstitial) {
    print("Interstitial ad loaded.")
  }

  /// Tells the delegate an ad request failed.
  func interstitial(_ ad: GADInterstitial, didFailToReceiveAdWithError error: GADRequestError) {
    print("Interstitial ad failed to load with error: \(error.localizedDescription)")
  }
}

Objective-C

@import GoogleMobileAds;
@import UIKit;

@interface ViewController () 

@property(nonatomic, strong) GADInterstitial *interstitial;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];
  self.interstitial = [[GADInterstitial alloc]
      initWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910"];
  self.interstitial.delegate = self;
  GADRequest *request = [GADRequest request];
  [self.interstitial loadRequest:request];
}

/// Tells the delegate an ad request succeeded.
- (void)interstitialDidReceiveAd:(GADInterstitial *)ad {
  NSLog(@"Insterstitial ad loaded.");
}

/// Tells the delegate an ad request failed.
- (void)interstitial:(GADInterstitial *)ad
    didFailToReceiveAdWithError:(GADRequestError *)error {
  NSLog(@"Interstitial ad failed to load with error: %@", [error localizedDescription]);
}

v8

Swift

import GoogleMobileAds
import UIKit

class ViewController: UIViewController, GADFullScreenContentDelegate {

  var interstitial: GADInterstitialAd?

  override func viewDidLoad() {
    super.viewDidLoad()
    let request = GADRequest()
    GADInterstitialAd.load(withAdUnitID:"ca-app-pub-8123415297019784/4985798738",
                                request: request,
                      completionHandler: { (ad, error) in
                        if let error = error {
                          print("Failed to load interstitial ad with error: \(error.localizedDescription)")
                          return
                        }
                        self.interstitial = ad
                        self.interstitial.fullScreenContentDelegate = self
                      }
    )
  }
}

Objective-C

@import GoogleMobileAds;
@import UIKit;

@interface ViewController () 

@property(nonatomic, strong) GADInterstitialAd *interstitial;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];
  GADRequest *request = [GADRequest request];
  [GADInterstitialAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910"
                              request:request
                    completionHandler:^(GADInterstitialAd *ad, NSError *error) {
    if (error) {
      NSLog(@"Failed to load interstitial ad with error: %@", [error localizedDescription]);
      return;
    }
    self.interstitial = ad;
    self.interstitial.fullScreenContentDelegate = self;
  }];
}

Annuncio display

Versione 7

Swift

func showInterstitial() {
  ...
  if interstitial.isReady {
    interstitial.present(fromRootViewController: self)
  } else {
    print("Ad wasn't ready")
  }
}

Objective-C

- (void)showInterstitial: {
  ...
  if (self.interstitial.isReady) {
    [self.interstitial presentFromRootViewController:self];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

v8

Swift

func showInterstitial() {
  ...
  if let ad = interstitial {
    ad.present(fromRootViewController: self)
  } else {
    print("Ad wasn't ready")
  }
}

Objective-C

- (void)showInterstitial: {
  ...
  if (self.interstitial) {
    [self.interstitial presentFromRootViewController:self];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

Eventi di annunci di presentazione

Gli snippet di codice riportati di seguito mostrano come gestire i callback quando l'annuncio viene visualizzato (con esito positivo o negativo) e quando viene ignorato.

Versione 7

Swift

override func viewDidLoad() {
  super.viewDidLoad()
  interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/4411468910")
  interstitial.delegate = self
  ...
}

/// Tells the delegate that an interstitial will be presented.
func interstitialWillPresentScreen(_ ad: GADInterstitial) {
  print("Interstitial ad will be presented.")
}

/// Tells the delegate the interstitial is to be animated off the screen.
func interstitialWillDismissScreen(_ ad: GADInterstitial) {
  print("Interstitial ad will be dismissed.")
}

/// Tells the delegate the interstitial had been animated off the screen.
func interstitialDidDismissScreen(_ ad: GADInterstitial) {
  print("Interstitial ad dismissed.")
}

/// Tells the delegate that a user click will open another app
/// (such as the App Store), backgrounding the current app.
///
/// This is not a reliable callback for an ad click event and is removed in
/// version 8. If you wish to listen to an ad causing a user to leave the app,
/// use applicationWillResignActive: or sceneWillResignActive: instead.
func interstitialWillLeaveApplication(_ ad: GADInterstitial) {
  print("Interstitial ad will leave application.")
}

Objective-C

- (void)viewDidLoad {
  [super viewDidLoad];
  self.interstitial = [[GADInterstitial alloc] initWithAdUnitID:"ca-app-pub-3940256099942544/4411468910"];
  self.interstitial.delegate = self;
  ...
}

/// Tells the delegate that an interstitial will be presented.
- (void)interstitialWillPresentScreen:(GADInterstitial *)ad {
  NSLog(@"Interstitial ad will be presented.");
}

/// Tells the delegate the interstitial is to be animated off the screen.
- (void)interstitialWillDismissScreen:(GADInterstitial *)ad {
  NSLog(@"Interstitial ad will be dismissed.");
}

/// Tells the delegate the interstitial had been animated off the screen.
- (void)interstitialDidDismissScreen:(GADInterstitial *)ad {
  NSLog(@"Interstitial ad dismissed.");
}

/// Tells the delegate that a user click will open another app
/// (such as the App Store), backgrounding the current app.
///
/// This is not a reliable callback for an ad click event and is removed in
/// version 8. If you wish to listen to an ad causing a user to leave the app,
/// use applicationWillResignActive: or sceneWillResignActive: instead.
- (void)interstitialWillLeaveApplication:(GADInterstitial *)ad {
  NSLog(@"Interstitial ad will leave application.");
}

v8

Swift

override func viewDidLoad() {
  super.viewDidLoad()
  let request = GADRequest()
  GADInterstitialAd.load(withAdUnitID:"ca-app-pub-8123415297019784/4985798738",
                              request: request,
                    completionHandler: { (ad, error) in
                      if let error = error {
                        print(error.localizedDescription)
                        return
                      }
                      self.interstitial = ad
                      self.interstitial.fullScreenContentDelegate = self
                    }
  )
}

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

func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {
  print("Ad failed to present full screen content with error \(error.localizedDescription).")
}

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

Objective-C

- (void)viewDidLoad {
  [super viewDidLoad];
  GADRequest *request = [GADRequest request];
  [GADInterstitialAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910"
                              request:request
                    completionHandler:^(GADInterstitialAd *ad, NSError *error) {
    if (error) {
      NSLog(@"interstitial:didFailToReceiveAdWithError: %@", [error localizedDescription])
      return;
    }
    self.interstitial = ad;
    self.interstitial.fullScreenContentDelegate = self;
  }];
}

- (void)adDidPresentFullScreenContent:(id)ad {
  NSLog(@"Ad did present full screen content.");
}

- (void)ad:(id)ad didFailToPresentFullScreenContentWithError:(NSError *)error {
  NSLog(@"Ad failed to present full screen content with error %@.", [error localizedDescription]);
}

- (void)adDidDismissFullScreenContent:(id)ad {
  NSLog(@"Ad did dismiss full screen content.");
}

Con premio

Carica annuncio

Versione 7

Swift

import GoogleMobileAds
import UIKit

class ViewController: UIViewController, GADRewardedAdDelegate {
  /// The rewarded ad.
  var rewardedAd: GADRewardedAd?

  override func viewDidLoad() {
    super.viewDidLoad()
    rewardedAd = GADRewardedAd(adUnitID: "ca-app-pub-3940256099942544/1712485313")
    rewardedAd.delegate = self
    rewardedAd?.load(GADRequest()) { error in
      if let error = error {
        print("Rewarded ad failed to load with error: \(error.localizedDescription)")
      } else {
        print("Rewarded ad loaded.")
      }
    }
  }
}

Objective-C

@import GoogleMobileAds;
@import UIKit;

@interface ViewController () 

@property(nonatomic, strong) GADRewardedAd *rewardedAd;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  self.rewardedAd = [[GADRewardedAd alloc]
      initWithAdUnitID:@"ca-app-pub-3940256099942544/1712485313"];
  self.rewardedAd.delegate = self;
  GADRequest *request = [GADRequest request];
  [self.rewardedAd loadRequest:request completionHandler:^(GADRequestError * _Nullable error) {
    if (error) {
      NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]);
    } else {
      NSLog(@"Rewarded ad loaded.");
    }
  }];
}

v8

Swift

import GoogleMobileAds
import UIKit

class ViewController: UIViewController, GADFullScreenContentDelegate {
  /// The rewarded ad.
  var rewardedAd: GADRewardedAd?

  override func viewDidLoad() {
  super.viewDidLoad()
  let request = GADRequest()
  GADRewardedAd.load(withAdUnitID: "ca-app-pub-8123415297019784/9501821136",
                          request: request, completionHandler: { (ad, error) in
                            if let error = error {
                              print("Rewarded ad failed to load with error: \(error.localizedDescription)")
                              return
                            }
                            self.rewardedAd = ad
                            self.rewardedAd?.fullScreenContentDelegate = self
                          }
  )
  }
}

Objective-C

@import GoogleMobileAds;
@import UIKit;

@interface ViewController () 

@property(nonatomic, strong) GADRewardedAd *rewardedAd;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  GADRequest *request = [GADRequest request];
  [GADRewardedAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/1712485313"
                          request:request
                completionHandler:^(GADRewardedAd *ad, NSError *error) {
    if (error) {
      NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]);
      return;
    }
    self.rewardedAd = ad;
    NSLog(@"Rewarded ad loaded.");
    self.rewardedAd.fullScreenContentDelegate = self;
}

Mostrare l'annuncio e gestire il premio

Gli annunci con premio richiedono di gestire l'evento quando un utente guadagna un premio. Con la versione 7 dell'API GADRewardedAd, puoi implementare rewardedAd:userDidEarnReward: nell'ambito del protocollo GADRewardedAdDelegate. Per la versione 8, devi implementare GADUserDidEarnRewardHandler per presentare l'annuncio.

Versione 7

Swift

func showRewardedAd() {
  ...
  if rewardedAd.isReady {
    rewardedAd.present(fromRootViewController: self delegate:self)
  } else {
    print("Ad wasn't ready")
  }
}

/// Tells the delegate that the user earned a reward.
func rewardedAd(_ rewardedAd: GADRewardedAd, userDidEarnReward: GADAdReward) {
  // TODO: Reward the user.
}

Objective-C

- (void)showRewardedAd: {
  ...
  if (self.rewardedAd.isReady) {
    [self.rewardedAd presentFromRootViewController:self delegate:self];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

/// Tells the delegate that the user earned a reward.
- (void)rewardedAd:(GADRewardedAd *)rewardedAd userDidEarnReward:(GADAdReward *)reward {
  // TODO: Reward the user.
}

v8

Swift

func showRewardedAd() {
  ...
  if let ad = rewardedAd {
      ad.present(fromRootViewController: self,
               userDidEarnRewardHandler: {
                 let reward = ad.adReward
                 // TODO: Reward the user.
               }
      )
  } else {
    print("Ad wasn't ready")
  }
}

Objective-C

- (void)showRewardedAd: {
  ...
  if (self.rewardedAd) {
    [self.rewardedAd presentFromRootViewController:self
                          userDidEarnRewardHandler:^ {
      GADAdReward *reward = self.rewardedAd.adReward;
      // TODO: Reward the user.
    }];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

Eventi di annunci di presentazione

Con l'API GADRewardedAd, passi un GADRewardedAdDelegate al metodo che presenta l'annuncio. Con l'API GADRewardedAd, imposti un GADFullscreenContentDelegate come proprietà nell'annuncio prima di presentarlo.

Versione 7

Swift

func showRewardedAd() {
  ...
  if rewardedAd.isReady {
    rewardedAd.present(fromRootViewController: self delegate:self)
  } else {
    print("Ad wasn't ready")
  }
}

/// Tells the delegate that the rewarded ad was presented.
func rewardedAdDidPresent(_ rewardedAd: GADRewardedAd) {
  print("Rewarded ad presented.")
}
/// Tells the delegate that the rewarded ad was dismissed.
func rewardedAdDidDismiss(_ rewardedAd: GADRewardedAd) {
  print("Rewarded ad dismissed.")
}
/// Tells the delegate that the rewarded ad failed to present.
func rewardedAd(_ rewardedAd: GADRewardedAd, didFailToPresentWithError error: Error) {
  print("Rewarded ad failed to present with error: \(error.localizedDescription).")
}

Objective-C

- (void)showRewardedAd: {
  ...
  if (self.rewardedAd.isReady) {
    [self.rewardedAd presentFromRootViewController:self delegate:self];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

/// Tells the delegate that the rewarded ad was presented.
- (void)rewardedAdDidPresent:(GADRewardedAd *)rewardedAd {
  NSLog(@"Rewarded ad presented.");
}

/// Tells the delegate that the rewarded ad failed to present.
- (void)rewardedAd:(GADRewardedAd *)rewardedAd didFailToPresentWithError:(NSError *)error {
  NSLog(@"Rewarded ad failed to present with error: %@",
        [error localizedDescription]);
}

/// Tells the delegate that the rewarded ad was dismissed.
- (void)rewardedAdDidDismiss:(GADRewardedAd *)rewardedAd {
  NSLog(@"Rewarded ad dismissed.");
}

v8

Swift

override func viewDidLoad() {
  super.viewDidLoad()
  let request = GADRequest()
  GADRewardedAd.load(withAdUnitID: "ca-app-pub-8123415297019784/9501821136",
                          request: request, completionHandler: { (ad, error) in
                            if let error = error {
                              print(error.localizedDescription)
                              return
                            }
                            self.rewardedAd = ad
                            self.rewardedAd?.fullScreenContentDelegate = self
                          }
  )
}

/// Tells the delegate that the rewarded ad was presented.
func adDidPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
  print("Rewarded ad presented.")
}
/// Tells the delegate that the rewarded ad was dismissed.
func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
  print("Rewarded ad dismissed.")
}
/// Tells the delegate that the rewarded ad failed to present.
func ad(_ ad: GADFullScreenPresentingAd,
    didFailToPresentFullScreenContentWithError error: Error) {
  print("Rewarded ad failed to present with error: \(error.localizedDescription).")
}

Objective-C

- (void)viewDidLoad {
  [super viewDidLoad];

  GADRequest *request = [GADRequest request];
  [GADRewardedAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/1712485313"
                          request:request
                completionHandler:^(GADRewardedAd *ad, NSError *error) {
    if (error) {
      NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]);
      return;
    }
    self.rewardedAd = ad;
    NSLog(@"Rewarded ad loaded.");
    self.rewardedAd.fullScreenContentDelegate = self;
}

/// Tells the delegate that the rewarded ad was presented.
- (void)adDidPresentFullScreenContent:(id)ad {
  NSLog(@"Rewarded ad presented.");
}

/// Tells the delegate that the rewarded ad failed to present.
- (void)ad:(id)ad
    didFailToPresentFullScreenContentWithError:(NSError *)error {
  NSLog(@"Rewarded ad failed to present with error: %@",
       [error localizedDescription]);
}

/// Tells the delegate that the rewarded ad was dismissed.
- (void)adDidDismissFullScreenContent:(id)ad {
  NSLog(@"Rewarded ad dismissed.");
}

Rimozione dell'API GADRewardBasedVideoAd precedente

La nuova API GADRewardedAd è stata introdotta per la prima volta a marzo 2019 ed è stata l'API con premio preferita per oltre 18 mesi. Ha subito più miglioramenti rispetto all'APIGADRewardedBasedVideoAd precedente, inclusa la possibilità di caricare più di un annuncio con premio alla volta.

L'API GADRewardedBasedVideoAd precedente viene rimossa nella versione 8.0.0 dell'SDK.

Ritiro dei banner intelligenti a favore dei banner adattivi

Gli annunci banner intelligenti non sono più supportati in favore degli annunci banner adattivi. I banner adattivi offrono un rendimento superiore e una maggiore flessibilità per impostare la larghezza dell'annuncio. Se preferisci continuare a utilizzare i banner a larghezza intera, puoi farlo anche con i banner adattivi, come mostrato nel seguente snippet di codice:

Swift

class ViewController: UIViewController {

  override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    // Note: The safe area is not known until viewWillAppear.
    let adSize = getFullWidthAdaptiveAdSize()
  }

  func getFullWidthAdaptiveAdSize() -> GADAdSize {
    // Here safe area is taken into account, hence the view frame is used after the
    // view has been laid out.
    let frame = { () -> CGRect in
      if #available(iOS 11.0, *) {
        return view.frame.inset(by: view.safeAreaInsets)
      } else {
        return view.frame
      }
    }()
    return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(frame.size.width)
  }
}

Objective-C

@implementation ViewController

- (void)viewDidAppear:(BOOL)animated {
  [super viewDidAppear:animated];
  // Note: The safe area is not known until viewWillAppear.
  GADAdSize adSize = [self getFullWidthAdaptiveAdSize];
}

- (GADAdSize)getFullWidthAdaptiveAdSize {
  CGRect frame = self.view.frame;
  // Here safe area is taken into account, hence the view frame is used after
  // the view has been laid out.
  if (@available(iOS 11.0, *)) {
    frame = UIEdgeInsetsInsetRect(self.view.frame, self.view.safeAreaInsets);
  }
  return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(frame.size.width);
}

@end

Rimozione del callback per la richiesta di recesso

Il callback willLeaveApplication per tutti i formati degli annunci è stato rimosso a favore dei metodi applicationDidEnterBackground: e sceneDidEnterBackground:. L'utilizzo di API a livello di sistema operativo ti avvisa ogni volta che gli utenti escono dalla tua app, indipendentemente dal fatto che sia o meno dovuto a un'interazione con l'annuncio.

Tieni presente che il callback willLeaveApplication non è mai stato pensato come gestore dei clic sugli annunci e fare affidamento su questo callback per registrare i clic non ha prodotto una metrica accurata. Ad esempio, un clic sull'icona AdChoices che ha avviato un browser esterno ha richiamato il callout, ma non è stato conteggiato un clic.

Ridenominazioni dei corsi

La tabella seguente elenca i nomi di classi specifici che sono stati modificati o rimossi nella versione 8. In sintesi:

  • Tutti i corsi correlati a GADUnifiedNativeAd sono stati rinominati in GADNativeAd.
  • GADRewardBasedVideoAd, GADNativeExpressAdView e GADInstreamAd sono stati rimossi.
  • Tutti i corsi con il prefisso DFP sono stati sostituiti con un prefisso GAM.
Classe v7.68.0 Classe v8.0.0
DFPBannerView GAMBannerView
DFPBannerViewOptions GAMBannerViewOptions
DFPInterstitial GAMInterstitialAd
DFPRequest GAMRequest
GADRequestError NSError
GADUnifiedNativeAdView GADNativeAdView
GADUnifiedNativeAd GADNativeAd
GADUnifiedNativeAdAssetIdentifiers GADNativeAdAssetIdentifiers
GADUnifiedNativeAdDelegate GADNativeAdDelegate
GADUnifiedNativeAdUnconfirmedClickDelegate GADNativeAdUnconfirmedClickDelegate
GADNativeCustomTemplateAd GADCustomNativeAd
GADNativeCustomTemplateAdLoaderDelegate GADCustomNativeAdLoaderDelegate
GADNativeAdDelegate GADCustomNativeAdDelegate
GADInAppPurchase Rimosso
GADInterstitial GADInterstitialAd
GADNativeExpressAdView Rimosso
GADRewardBasedVideoAd Rimosso
GADInstreamAd Rimosso
GADInstreamAdView Rimosso

Metodi rimossi/sostituiri

La tabella seguente elenca le modifiche specifiche nella versione 8. In sintesi:

  • I metodi e le proprietà precedentemente deprecati sono stati rimossi.
  • I metodi del delegato -willLeaveApplication: sono stati rimossi per tutti i formati.
  • Il nome della classe della rete pubblicitaria è stato spostato nella proprietà GADResponseInfo.
  • L'identificatore del dispositivo di test è stato spostato nella proprietà GADRequestConfiguration.
Classe v7.68.0 API v7.68.0 API v8.0.0 Note
GADMobileAds +configureWithApplicationID: -startWithCompletionHandler: L'ID app è ora impostato in Info.plist.
+disableAutomatedInAppPurchaseReporting -disableAutomatedInAppPurchaseReporting
+disableSDKCrashReporting -disableSDKCrashReporting
GADRequest testDevices GADRequestConfiguration.testdeviceidentifiers La proprietà testDeviceIdentifiers si applica a tutte le richieste di annunci, mentre la precedente proprietà testDevices veniva impostata per richiesta.
genere Rimosso
compleanno Rimosso
+sdkVersion GADMobileAds.sharedInstance.sdkVersion
-setBirthdayWithMonth:day:year: Rimosso
-setLocationWithDescription: -setLocationWithLatitude:longitude:accuracy:
-tagForChildDirectedTreatment: [GADMobileAds.sharedInstance.requestConfiguration tagForChildDirectedTreatment]
GADErrorCode kGADError* GADError* Il prefisso k viene omesso da tutte le costanti dei codici di errore.
GADBannerView hasAutoRefreshed autoloadEnabled
inAppPurchaseDelegate Rimosso
mediatedAdView Rimosso
adNetworkClassName responseInfo.adNetworkClassName
DFPBannerView -setValidAdSizesWithSizes: -setValidAdSizes:
DFPBannerViewOptions -adSizeDelegate Rimosso
GADBannerViewDelegate -adViewDidReceiveAd: -bannerViewDidReceiveAd:
-adView:didFailToReceiveAdWithError: -bannerView:didFailToReceiveAdWithError:
-adViewWillPresentScreen: -bannerViewWillPresentScreen:
-adViewWillDismissScreen: -bannerViewWillDismissScreen:
-adViewDidDismissScreen: -bannerViewDidDismissScreen:
-adViewWillLeaveApplication: Rimosso
GADNativeCustomTemplateAd templateID GADCustomNativeAd.formatID
-performClickOnAssetWithKey:customClickHandler: -performClickOnAssetWithKey:
GADNativeAdImageAdLoaderOptions preferredImageOrientation GADNativeAdMediaAdOptions.mediaAspectRatio
GADInterstitial inAppPurchaseDelegate Rimosso
isReady Rimosso Utilizza invece canPresentFromRootViewController:error:.
hasBeenUsed Rimosso
-init -initWithAdUnitID:
-setAdUnitID: -initWithAdUnitID:
adNetworkClassName responseInfo.adNetworkClassName
-interstitialWillLeaveApplication: Rimosso
GADUnifiedNativeAd videoController mediaContent.videoController
adNetworkClassName responseInfo.adNetworkClassName