Questa pagina descrive le migrazioni per le versioni attuali e precedenti di Google Mobile Ads SDK per iOS. Prevediamo di rilasciare la versione 13.0.0 a febbraio 2026.
Eseguire la migrazione dalla versione 12 alla versione 13
Aumento della destinazione di deployment minima
Il target di deployment minimo è stato aumentato a iOS 13.
Modifiche alle API per le dimensioni dei banner adattivi ancorati
La versione 13.0.0 ritira le API per le dimensioni dei banner adattivi ancorati esistenti e introduce le API per le dimensioni degli annunci banner adattivi ancorati di grandi dimensioni. Google Mobile Ads SDK può erogare la domanda di video negli annunci banner utilizzando le nuove API per le dimensioni dei banner adattivi ancorati di grandi dimensioni.
La seguente tabella mostra in dettaglio le API di ridimensionamento ritirate e le relative sostituzioni:
| v12 (ritirata) | v13 (sostituzione) |
|---|---|
GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADLargeAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADLandscapeAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADLargeLandscapeAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADLargePortraitAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
Supporto continuo della concorrenza di Swift 6
La versione 13.0.0 continua ad aggiungere il supporto per la concorrenza rigorosa di Swift 6.
È stata aggiunta un'applicazione più rigorosa dei tipi per l'array neighboringContentURLStrings
A partire dalla versione 13.0.0, Google Mobile Ads SDK genera un'eccezione se viene rilevato un oggetto che non è di tipo String nell'array neighboringContentURLStrings.
Esegui la migrazione dalla versione 11 alla versione 12
Esegui l'upgrade a Xcode 16.0
La versione minima supportata di Xcode è stata aumentata a 16.0.
Supporto per la denominazione Swift
La versione 12.0.0 include modifiche per seguire le convenzioni di denominazione 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 dei corsi:
- Rimosso il prefisso
GADdai nomi di tutti i tipi. - Il prefisso
GAMè stato rinominato inAdManager. - Il prefisso
GADMè stato rinominato inMediation.
Risolvi gli errori
Il modo migliore per risolvere gli errori derivanti da queste modifiche è apportare una correzione 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. I seguenti spazi dei nomi di esempio
Google Mobile Ads SDK classe Request:
import GoogleMobileAds
...
var request: GoogleMobileAds.Request?
Elenco dettagliato delle modifiche di Swift
Le seguenti tabelle 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:) |
Impostare parametri di targeting personalizzati
Per impostare un targeting personalizzato su una richiesta di annuncio, utilizza
customTargeting.
Modifiche all'API per controllare lo stato di disattivazione dell'audio dei video
La proprietà isMuted e il metodo setMute: su GADVideoController sono
sostituiti da una proprietà muted.
Modifiche agli annunci adattivi in linea
Per ottimizzare l'utilizzo dello spazio, gli annunci adattivi in linea inizialmente non occupano spazio
nel frame. La chiamata di CGSizeFromGADAdSize(_:) con
una dimensione dell'annuncio adattivo in linea ora restituisce l'altezza 0 finché l'SDK Google Mobile Ads
non restituisce un annuncio.
Rimossi gli annunci della rete di ricerca personalizzata
Le seguenti classi vengono rimosse senza sostituzione:
GADDynamicHeightSearchBannerViewGADDynamicHeightSearchRequestGADSearchBannerView
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. |
Rimozione di GADSimulatorID
GADSimulatorID rimosso. I simulatori sono già in modalità di test per impostazione predefinita.
Modifiche al targeting personalizzato
Il dizionario customTargeting su GADRequest ora utilizza Any anziché
String come tipo di valore. In questo modo puoi trasmettere valori numerici all'API.
Modifiche ai parametri degli extra
- Il passaggio di chiavi in
additionalParametersnon applica più il targeting personalizzato alle richieste di annunci Ad Manager. Per applicare il targeting personalizzato, vedi Targeting personalizzato.
- Il passaggio della chiave
max_ad_content_ratinginadditionalParametersnon è più supportato. Per impostare una classificazione massima dei contenuti degli annunci, vedi Filtro dei contenuti degli annunci.
Esegui la migrazione dalla versione 10 alla versione 11
Destinazione di deployment minima
Il target di deployment minimo è stato aumentato a iOS 12.
Versione minima di Xcode
La versione minima supportata di Xcode è stata aumentata a 15.1.
Interruzione della pubblicazione degli annunci su iOS 12
La versione 11.0.0 di Google Mobile Ads SDK pubblica annunci solo sui dispositivi con iOS 13 e versioni successive.
Rimossa la dipendenza GoogleAppMeasurement
Nella versione 11.0.0, la dipendenza da
GoogleAppMeasurement è stata
rimossa. Questa dipendenza che alimentava il pulsante di attivazione/disattivazione delle metriche utente in AdMob verrà
ritirata all'inizio del 2024. Per
continuare a raccogliere metriche utente in AdMob,
collega l'app monetizzata con 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: è annullabile. Se viene passato nil, l'annuncio viene
presentato dal controller di visualizzazione di primo livello nella gerarchia dei controller di visualizzazione.
Metodi rimossi
I seguenti metodi vengono rimossi.
| v11.0.0 Type | Metodo | Note |
|---|---|---|
| GADAppOpenAd | load(withAdUnitID adUnitID: String, request: GADRequest?, orientation: UIInterfaceOrientation) |
Utilizza invece load(withAdUnitID adUnitID: String, request: GADRequest?). |
| GADMediationBannerAdEventDelegate | willBackgroundApplication() |
Nessuna sostituzione. |
| GADMediationInterstitialAdEventDelegate | willBackgroundApplication() |
Nessuna sostituzione. |
| GADMediationNativeAdEventDelegate | willBackgroundApplication() |
Nessuna sostituzione. |
| GADMediationRewardedAdEventDelegate | didRewardUser(with reward: GADAdReward) |
Utilizza invece 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.
| v11.0.0 Class | Proprietà | Note |
|---|---|---|
| GADMediationAdConfiguration | hasUserLocation | Nessuna sostituzione. |
| userLatitude | ||
| userLongitude | ||
| userLocationAccuracyInMeters | ||
| childDirectedTreatment | Utilizza invece GADMobileAds.sharedInstance.requestConfiguration.tagForChildDirectedTreatment. |
|
| GADResponseInfo | adNetworkClassName | Utilizza invece adNetworkClassName di loadedAdNetworkResponseInfo. |
Rimozione di GADAdFormatUnknown
GADAdFormatUnknown rimosso senza sostituzione.
Modifiche alla registrazione della versione dell'SDK
La versione 11.0.0 rimuove sdkVersion. Per registrare la versione Google Mobile Ads SDK,
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 relativo
delegate
non è conforme al protocollo delegato dei tipi di annunci richiesti. In precedenza, l'errore
si verificava dopo l'invio della richiesta di annuncio.
Modifiche al comportamento dei test
Consulta la tabella che mostra le condizioni aggiornate per quando le seguenti proprietà restituiscono true.
| Classe | Proprietà |
|---|---|
| GADMediationAdConfiguration | isTestRequest |
| GADCustomEventRequest | isTesting |
| v10.0.0 | v11.0.0 |
|
|
Esegui la migrazione dalla versione 9 alla versione 10
Interruzione della pubblicazione degli annunci su iOS 11
Google Mobile Ads SDK versione 10.0.0 pubblica annunci solo sui dispositivi con iOS 12 e versioni successive.
L'aggiornamento alla versione 10.0.0 di Google Mobile Ads SDK non interromperà il funzionamento dell'app sui dispositivi iOS 11 e iOS 10, tuttavia non verranno pubblicati annunci su questi dispositivi.
Requisito dell'ID app Ad Manager
L'ID app Ad Manager è ora obbligatorio in Info.plist per tutte le app Ad Manager e
richiede il formato ca-app-pub-################~##########. Per maggiori dettagli, consulta Aggiornare il file Info.plist.
Requisito di GoogleAppMeasurement.xcframework
GoogleAppMeasurement.xcframework è ora obbligatorio per tutte le app Ad Manager. Se installi Google Mobile Ads SDK tramite Cocoapods o Swift Package Manager, non è necessaria alcuna azione aggiuntiva. Se installi i framework manualmente, consulta la sezione Download manuale per maggiori dettagli.
La creazione con bitcode non è più supportata
La disattivazione di bitcode nelle app mobile è ora necessaria per integrare Google Mobile Ads SDK.
Tipi rimossi
| Tipo | Note |
|---|---|
| GADGender | Nessuna sostituzione. |
| GADMRewardBasedVideoAdNetworkAdapterProtocol | Tutti gli adattatori di mediazione con premio elencati in Scegli reti 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 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 viene interrotta su iOS 10
La versione minima di iOS Google Mobile Ads SDK versione 9.0.0 supporta iOS 11.
L'aggiornamento alla versione 9.0.0 di Google Mobile Ads SDK non interromperà il funzionamento dell'app sui dispositivi iOS 10, tuttavia 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 verrà visualizzato un messaggio di errore.
A seconda del layout specifico dei controller di visualizzazione nella tua app, potresti non
dover apportare modifiche per assicurarti che ciò avvenga. Valuta se devi impostare la proprietà
childViewControllerForStatusBarHidden
nel rootViewController del tuo annuncio.
Rinomina adDidPresentFullScreenContent: in adWillPresentFullScreenContent:
Non sono previste modifiche al comportamento. Il metodo del delegato viene richiamato subito prima che l'annuncio venga visualizzato, quindi il nuovo nome del metodo riflette meglio la sua funzionalità.
Rimuovi 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 il targeting degli annunci. Utilizza
API di terze parti per fornire le informazioni alle reti pubblicitarie di terze parti, se
necessario.
Ritiro delle interfacce degli eventi personalizzati
Gli eventi personalizzati consentono ai publisher che utilizzano la mediazione Ad Manager di aggiungere la mediazione a cascata per una rete pubblicitaria che non è una delle reti pubblicitarie supportate.
Tutti i protocolli di eventi personalizzati sono ritirati. Utilizza invece i protocolli esistenti
GADMediationAdapter
e
GADMediationAdEventDelegate
per ottenere le stesse funzionalità. Questa modifica migliora la chiarezza e
ti consente di creare eventi personalizzati per gli annunci con premio e interscroller che
non erano disponibili in precedenza.
API
La tabella seguente elenca le API degli adattatori di mediazione corrispondenti alle API degli 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 di completamento del caricamento di ogni funzione di caricamento
della classe GADMediationAdapter
|
|
-init |
-init |
|
-requestBannerAd:parameter: |
-loadBannerForAdConfiguration: |
|
-requestInterstitialAdWith |
-loadInterstitialFor |
|
-requestNativeAdWithParameter:
|
-loadNativeAdFor |
|
| N/D | -loadInterscrollerAdFor |
|
| N/D | -loadRewardedAdFor |
|
-presentFromRootViewController:
|
-presentFromViewController: |
|
-handlesUserClicks |
-handlesUserClicks |
|
-handlesUserImpressions |
-handlesUserImpressions |
|
Metodi di delega
La tabella seguente elenca i metodi delegati per gli eventi dell'annuncio di mediazione corrispondenti ai metodi delegati 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 di completamento del caricamento di
ogni funzione di caricamento nella classe GADMediationAdapter
|
|
-customEventBanner:didFailAd:-customEventInterstitial:didFailAd:
|
||
-customEventBannerWasClicked:-customEventInterstitialWasClicked:
|
-reportClick |
|
-customEventBannerWill-customEventInterstitialWill
|
-willPresentFullScreenView |
|
-customEventBannerWill-customEventInterstitialWill
|
-willDismissFullScreenView |
|
-customEventBannerDid-customEventInterstitialDid
|
-didDismissFullScreenView |
|
-customEventBannerWill-customEventInterstitialWill
|
-willBackgroundApplication |
|
viewControllerFor |
-[GADMediationBannerAd view] |
|
Altre costanti e altri metodi rimossi/sostituiti
| Modifiche a metodo, costante o proprietà | |
|---|---|
Costanti con prefisso kGAD-
|
Rimosso. Utilizza le costanti con il prefisso GAD-.
|
GADAdNetworkResponseInfo
|
credentials sono stati rimossi. Utilizza invece adUnitMapping.
|
GAMRequest
|
kGAMSimulatorID in GAMRequest è deprecato.
Utilizza GADSimulatorID in GADRequestConfiguration
invece.
|
GADCustomNativeAd
|
mediaView in GADCustomNativeAd è deprecato.
Utilizza invece mediaContent.
|
API per acquisti in-app in GoogleMobileAds |
Le API inAppPurchase in GoogleMobileAds sono state
rimosse.
|
Esegui la migrazione dalla versione 7 alla versione 8
La versione 8.0.0 di Google Mobile Ads SDK introduce alcune modifiche importanti, nonché alcuni ridenominazioni e rimozioni di API.
Aggiornamenti dell'API di formato a schermo intero
A partire dalla versione 8.0.0, gli annunci interstitial e con premio condividono uno stile generico di annuncio a schermo intero per una maggiore coerenza. Queste nuove API per gli annunci a schermo intero presentano due differenze principali rispetto alle API per gli annunci a schermo intero della versione 7:
Metodo statico della classe
load.L'approccio precedente per caricare/mostrare un annuncio a schermo intero è il seguente:
- Crea un'istanza dell'oggetto annuncio e mantieni un riferimento.
- Assegna un delegato che gestisca i callback di caricamento e visualizzazione.
- Carica un annuncio.
- Verifica se l'annuncio è caricato utilizzando
isReady. - Mostra l'annuncio.
Nella versione 8, l'approccio cambia leggermente. I callback di caricamento non fanno più parte di un delegato. Vengono invece passati al metodo
loadcome gestore del completamento:- Chiama un metodo di caricamento statico nella classe dell'annuncio e fornisci un gestore di completamento del caricamento.
- Nel callback di completamento del caricamento, mantieni un riferimento all'annuncio caricato restituito.
- Assegna un delegato che gestisca i callback dello spettacolo.
- Mostra l'annuncio.
Il nuovo approccio offre i seguenti vantaggi:
- Non avrai mai un riferimento a un annuncio non caricato.
- Non devi conservare un oggetto dell'annuncio durante il caricamento.
Eventi annuncio coerenti.
Tipo di evento API esistente API v8 Carica eventi GADInterstitialDelegateoGADRewardedAdDelegateGAMInterstitialAdLoadCompletionHandleroGADRewardedAdLoadCompletionHandlerEventi di presentazione GADFullScreenContentDelegateIn precedenza, per ascoltare gli eventi degli annunci, registravi una classe che implementava il protocollo
GADInterstitialDelegatealla proprietà delegata di un interstitial o registravi una classe che implementava il protocolloGADRewardedAdDelegatealla proprietà delegata di un annuncio con premio, a seconda del formato che utilizzi. Lo stesso delegato aveva metodi correlati sia al ciclo di vita del caricamento sia della presentazione di un annuncio.Con la versione 8, gli eventi di caricamento e presentazione sono separati. Ora puoi registrare un
GADFullScreenContentDelegatein qualsiasi momento prima della pubblicazione di un annuncio, anziché dover impostare un singolo delegato prima del caricamento dell'annuncio. Gli eventi di caricamento degli annunci, specifici per ogni formato, vengono spostati in un unico gestore di completamento del caricamento passato nel metodo di caricamento.
Interstitial
Carica annuncio
I seguenti snippet di codice mostrano come caricare un annuncio interstitial e ascoltare gli eventi quando l'annuncio viene caricato correttamente o meno.
Versione 7
Swift
import GoogleMobileAds import UIKit class ViewController: UIViewController, GADInterstitialDelegate { var interstitial: DFPInterstitial! override func viewDidLoad() { super.viewDidLoad() interstitial = DFPInterstitial(adUnitID: "/21775744923/example/interstitial") interstitial.delegate = self let request = GAMRequest() interstitial.load(request) } /// Tells the delegate an ad request succeeded. func interstitialDidReceiveAd(_ ad: DFPInterstitial) { print("Interstitial ad loaded.") } /// Tells the delegate an ad request failed. func interstitial(_ ad: DFPInterstitial, didFailToReceiveAdWithError error: GADRequestError) { print("Interstitial ad failed to load with error: \(error.localizedDescription)") } }
Objective-C
@import GoogleMobileAds; @import UIKit; @interface ViewController ()@property(nonatomic, strong) DFPInterstitial *interstitial; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.interstitial = [[DFPInterstitial alloc] initWithAdUnitID:@"/21775744923/example/interstitial"]; self.interstitial.delegate = self; GAMRequest *request = [GAMRequest request]; [self.interstitial loadRequest:request]; } /// Tells the delegate an ad request succeeded. - (void)interstitialDidReceiveAd:(DFPInterstitial *)ad { NSLog(@"Insterstitial ad loaded."); } /// Tells the delegate an ad request failed. - (void)interstitial:(DFPInterstitial *)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: GAMInterstitialAd? override func viewDidLoad() { super.viewDidLoad() let request = GAMRequest() GAMInterstitialAd.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) GAMInterstitialAd *interstitial; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; GAMRequest *request = [GAMRequest request]; [GAMInterstitialAd loadWithAdUnitID:@"/21775744923/example/interstitial" request:request completionHandler:^(GAMInterstitialAd *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 annuncio della presentazione
I seguenti snippet di codice mostrano come gestire i callback quando l'annuncio viene visualizzato (correttamente o meno) e quando viene chiuso.
Versione 7
Swift
override func viewDidLoad() { super.viewDidLoad() interstitial = DFPInterstitial(adUnitID: "/21775744923/example/interstitial") interstitial.delegate = self ... } /// Tells the delegate that an interstitial will be presented. func interstitialWillPresentScreen(_ ad: DFPInterstitial) { print("Interstitial ad will be presented.") } /// Tells the delegate the interstitial is to be animated off the screen. func interstitialWillDismissScreen(_ ad: DFPInterstitial) { print("Interstitial ad will be dismissed.") } /// Tells the delegate the interstitial had been animated off the screen. func interstitialDidDismissScreen(_ ad: DFPInterstitial) { 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: DFPInterstitial) { print("Interstitial ad will leave application.") }
Objective-C
- (void)viewDidLoad { [super viewDidLoad]; self.interstitial = [[DFPInterstitial alloc] initWithAdUnitID:"/21775744923/example/interstitial"]; self.interstitial.delegate = self; ... } /// Tells the delegate that an interstitial will be presented. - (void)interstitialWillPresentScreen:(DFPInterstitial *)ad { NSLog(@"Interstitial ad will be presented."); } /// Tells the delegate the interstitial is to be animated off the screen. - (void)interstitialWillDismissScreen:(DFPInterstitial *)ad { NSLog(@"Interstitial ad will be dismissed."); } /// Tells the delegate the interstitial had been animated off the screen. - (void)interstitialDidDismissScreen:(DFPInterstitial *)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:(DFPInterstitial *)ad { NSLog(@"Interstitial ad will leave application."); }
v8
Swift
override func viewDidLoad() { super.viewDidLoad() let request = GAMRequest() GAMInterstitialAd.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]; GAMRequest *request = [GAMRequest request]; [GAMInterstitialAd loadWithAdUnitID:@"/21775744923/example/interstitial" request:request completionHandler:^(GAMInterstitialAd *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(GAMRequest()) { 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; GAMRequest *request = [GAMRequest 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 = GAMRequest() 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]; GAMRequest *request = [GAMRequest 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; }
Annuncio display e premio per l'handle
Gli annunci con premio richiedono la gestione dell'evento quando un utente guadagna un premio. Con
la versione 7 dell'API GADRewardedAd, implementi
rewardedAd:userDidEarnReward: come parte del protocollo GADRewardedAdDelegate.
Per la versione 8, implementa GADUserDidEarnRewardHandler per
mostrare 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 annuncio della presentazione
Con l'API GADRewardedAd passi un GADRewardedAdDelegate al metodo
che presenta l'annuncio. Con l'API GADRewardedAd, imposti un
GADFullscreenContentDelegate come proprietà dell'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 = GAMRequest() 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]; GAMRequest *request = [GAMRequest 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 GADRewardedBasedVideoAd legacy
La nuova
GADRewardedAd
API è stata introdotta per la prima volta nel marzo 2019 ed è stata l'API
premiata preferita per oltre 18 mesi. Ha subito più miglioramenti rispetto all'API
GADRewardedBasedVideoAd legacy, tra cui la possibilità di caricare più di un
annuncio con premio alla volta.
L'API GADRewardedBasedVideoAd legacy viene rimossa nella versione 8.0.0 dell'SDK.
Ritiro del banner intelligente a favore del banner adattivo
Gli annunci banner intelligenti non sono più supportati a favore degli annunci banner adattivi. I banner adattivi offrono prestazioni superiori e una maggiore flessibilità nella definizione della larghezza dell'annuncio. Se preferisci continuare a utilizzare i banner a larghezza intera, puoi comunque farlo utilizzando il banner adattivo, 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 dell'applicazione di assenza
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 ciò sia dovuto o meno a un'interazione con un annuncio.
Tieni presente che il callback willLeaveApplication non è mai stato pensato per essere
un gestore di clic sugli annunci e fare affidamento su questo callback per segnalare i clic non
produce una metrica accurata. Ad esempio, un clic sull'icona
AdChoices che ha avviato un browser esterno ha richiamato il callback, ma non ha conteggiato un
clic.
Ridenominazioni delle classi
La tabella seguente elenca i nomi delle classi specifici che sono stati modificati o rimossi nella versione 8. In sintesi:
- Tutti i corsi correlati a
GADUnifiedNativeAdsono stati rinominati inGADNativeAd. GADRewardBasedVideoAd,GADNativeExpressAdVieweGADInstreamAdsono stati rimossi.- Tutte le classi con il prefisso
DFPsono state sostituite con un prefissoGAM.
| v7.68.0 Class | v8.0.0 Class |
|---|---|
| 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/sostituiti
La tabella seguente elenca le modifiche specifiche nella versione 8. In sintesi:
- I metodi e le proprietà precedentemente deprecati sono stati rimossi.
- I metodi di delega
-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.
| v7.68.0 Class | API v7.68.0 | API v8.0.0 | Note |
|---|---|---|---|
| GADMobileAds | +configureWithApplicationID: | -startWithCompletionHandler: | L'ID app è ora impostato in Info.plist. |
| +disableAutomatedInApp |
-disableAutomatedInApp |
||
| +disableSDKCrashReporting | -disableSDKCrashReporting | ||
| GADRequest | testDevices | GADRequestConfiguration |
La proprietà testDeviceIdentifiers si applica a tutte le richieste di annunci, mentre la vecchia proprietà testDevices veniva impostata per richiesta. |
| gender | Rimosso | ||
| compleanno | Rimosso | ||
| +sdkVersion | GADMobileAds.sharedInstance |
||
| -setBirthday |
Rimosso | ||
| -setLocationWithDescription: | -setLocationWith |
||
| -tagForChildDirectedTreatment: | [GADMobileAds.sharedInstance.requestConfiguration tagForChildDirectedTreatment] | ||
| GADErrorCode | kGADError* | GADError* | Il prefisso k viene eliminato da tutte le costanti del codice di errore.
|
| GADBannerView | hasAutoRefreshed | autoloadEnabled | |
| inAppPurchaseDelegate | Rimosso | ||
| mediatedAdView | Rimosso | ||
| adNetworkClassName | responseInfo |
||
| DFPBannerView | -setValidAdSizesWithSizes: | -setValidAdSizes: | |
| DFPBannerViewOptions | -adSizeDelegate | Rimosso | |
| GADBannerViewDelegate | -adViewDidReceiveAd: | -bannerViewDidReceiveAd: | |
| -adView:didFailToReceive |
-bannerView:didFailToReceive |
||
| -adViewWillPresentScreen: | -bannerViewWillPresentScreen: | ||
| -adViewWillDismissScreen: | -bannerViewWillDismissScreen: | ||
| -adViewDidDismissScreen: | -bannerViewDidDismissScreen: | ||
| -adViewWillLeaveApplication: | Rimosso | ||
| GADNativeCustomTemplateAd | templateID | GADCustomNativeAd.formatID | |
| -performClickOnAssetWithKey: |
-performClickOnAssetWithKey: | ||
| GADNativeAdImageAd |
preferredImageOrientation | GADNativeAdMediaAdOptions |
|
| GADInterstitial | inAppPurchaseDelegate | Rimosso | |
| isReady | Rimosso | Utilizza invece canPresentFrom |
|
| hasBeenUsed | Rimosso | ||
| -init | -initWithAdUnitID: | ||
| -setAdUnitID: | -initWithAdUnitID: | ||
| adNetworkClassName | responseInfo |
||
| -interstitialWill |
Rimosso | ||
| GADUnifiedNativeAd | videoController | mediaContent.videoController | |
| adNetworkClassName | responseInfo |