Questa pagina illustra 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.
Esegui la migrazione dalla versione 12 alla versione 13
Target di deployment minimo aumentato
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 esistenti per le dimensioni dei banner adattivi ancorati e introduce le API per le dimensioni degli annunci banner adattivi ancorati di grandi dimensioni. Google Mobile Ads SDK può pubblicare la domanda di video negli annunci banner utilizzando le nuove API per le dimensioni dei banner adattivi ancorati di grandi dimensioni.
La tabella seguente descrive in dettaglio le API di dimensionamento 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.
Aggiunta un'applicazione più rigorosa del tipo 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 è un 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 alla 16.0.
Supporto per la denominazione Swift
La versione 12.0.0 include modifiche per seguire le convenzioni di denominazione delle linee guida per la progettazione delle API Swift. Queste modifiche riguardano solo Swift. Non sono state apportate modifiche ai nomi delle API Objective-C.
Modifiche al prefisso della classe
Ai prefissi delle classi sono state apportate le seguenti modifiche:
- 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 con Fix-It.
Risolvi i conflitti di nomi
Per risolvere i conflitti di denominazione, utilizza lo spazio dei nomi fornito dal modulo. Ad esempio, GADRequest ora si chiama Request. L'esempio seguente inserisce nello spazio dei nomi Google Mobile Ads SDK la classe Request:
import GoogleMobileAds
...
var request: GoogleMobileAds.Request?
Elenco dettagliato delle modifiche di Swift
Le tabelle seguenti 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:) |
Imposta i parametri di targeting personalizzato
Per impostare il targeting personalizzato su una richiesta di annuncio, utilizza customTargeting.
Modifiche alle API per il controllo dello stato di disattivazione 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 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.
Annunci della rete di ricerca personalizzata rimossi
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. |
GADSimulatorID rimosso
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 passare valori numerici all'API.
Modifiche ai parametri aggiuntivi
- Il passaggio delle chiavi a
additionalParametersnon applica più il targeting personalizzato alle richieste di annunci di Ad Manager. Per applicare il targeting personalizzato, consulta Targeting personalizzato.
- Il passaggio della chiave
max_ad_content_ratingaadditionalParametersnon è più supportato. Per impostare una classificazione massima dei contenuti degli annunci, consulta 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 Xcode minima
La versione minima supportata di Xcode è stata aumentata alla 15.1.
La pubblicazione degli annunci viene interrotta 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 supportava il pulsante di attivazione/disattivazione delle metriche utente in AdMob non sarà più disponibile all'inizio del 2024. Per continuare a raccogliere le 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 di visualizzazione in -canPresentFromRootViewController:error: e
-presentFromRootViewController: è nullable. Se viene passato nil, l'annuncio viene presentato dal view controller più in alto nella gerarchia dei view controller.
Metodi rimossi
I seguenti metodi sono stati rimossi.
| Tipo v11.0.0 | 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) |
Usa invece il descrittore 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 invece GADMobileAds.sharedInstance.requestConfiguration.tagForChildDirectedTreatment. |
|
| GADResponseInfo | adNetworkClassName | Utilizza invece adNetworkClassName da loadedAdNetworkResponseInfo. |
GADAdFormatUnknown rimosso
GADAdFormatUnknown rimosso senza sostituzione.
Modifiche alla versione dell'SDK di logging
La versione 11.0.0 rimuove sdkVersion. Per registrare la versione Google Mobile Ads SDK, utilizza invece 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 delegato dei tipi di annunci richiesti. In precedenza, l'operazione 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 la restituzione di true da parte delle seguenti proprietà.
| Classe | Proprietà |
|---|---|
| GADMediationAdConfiguration | isTestRequest |
| GADCustomEventRequest | isTesting |
| v10.0.0 | v11.0.0 |
|
|
Esegui la migrazione dalla versione 9 alla versione 10
La pubblicazione degli annunci viene interrotta su iOS 11
La versione 10.0.0 di Google Mobile Ads SDK pubblica annunci solo su dispositivi con iOS 12 e versioni successive.
L'upgrade alla versione 10.0.0 di Google Mobile Ads SDK non interromperà l'app sui dispositivi iOS 11 e iOS 10, ma 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 Aggiorna 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 è richiesta alcuna azione aggiuntiva. Se installi i framework manualmente, consulta la sezione Download manuale per maggiori dettagli.
La creazione con bitcode non è più supportata
Per integrare l'Google Mobile Ads SDK, ora è necessario disattivare il bitcode nelle app mobile.
Tipi rimossi
| Tipo | Note |
|---|---|
| GADGender | Nessuna sostituzione. |
| GADMRewardBasedVideoAdNetworkAdapterProtocol | Tutti gli adattatori di mediazione con premio elencati in Scegli le 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 |
Esegui la migrazione dalla versione 8 alla versione 9
La pubblicazione degli annunci viene interrotta su iOS 10
La versione minima di iOS supportata dalla versione 9.0.0 di Google Mobile Ads SDK è iOS 11.
L'upgrade alla versione 9.0.0 di Google Mobile Ads SDK non interromperà l'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. In caso contrario, 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 garantire questo comportamento. Valuta se devi impostare la proprietà childViewControllerForStatusBarHidden su rootViewController dell'annuncio.
Rinomina adDidPresentFullScreenContent: in adWillPresentFullScreenContent:
Non ci sono modifiche al comportamento. Il metodo del delegato viene richiamato subito prima della presentazione dell'annuncio, pertanto il nuovo nome del metodo riflette meglio la sua funzionalità.
Rimuovi l'API delle impostazioni di localizzazione su GADRequest
- (void)setLocationWithLatitude:longitude:accuracy: è stato eliminato da GADRequest perché i dati sulla posizione non vengono utilizzati da Google per il targeting degli annunci. Utilizza le 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 degli eventi personalizzati sono deprecati. 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 gli annunci interscroller, che in precedenza non erano disponibili.
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 del 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 delegati
La tabella seguente elenca i metodi delegati degli eventi degli annunci di mediazione corrispondenti ai metodi delegati degli 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 del caricamento degli annunci è incluso nel gestore del 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] |
|
Altri metodi e costanti rimossi/sostituiti
| Modifiche a metodi, costanti o proprietà | |
|---|---|
Costanti con prefisso kGAD-
|
Rimosso. Utilizza costanti con prefisso GAD-.
|
GADAdNetworkResponseInfo
|
credentials è stato rimosso. Utilizza invece adUnitMapping.
|
GAMRequest
|
kGAMSimulatorID in GAMRequest è deprecato.
Utilizza invece GADSimulatorID in GADRequestConfiguration.
|
GADCustomNativeAd
|
mediaView in GADCustomNativeAd è deprecato.
Usa invece il descrittore 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é alcune ridenominazioni e rimozioni di 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 di annuncio a schermo intero generico 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 di classe statico
load.L'approccio precedente per caricare/mostrare un annuncio a schermo intero è il seguente:
- Crea un'istanza di un oggetto annuncio e mantieni un riferimento.
- Assegna un delegato che gestisca i callback di caricamento e visualizzazione.
- Carica un annuncio.
- Verifica se l'annuncio è stato caricato utilizzando
isReady. - 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
loadcome gestore di completamento:- Chiama un metodo di caricamento statico nella classe dell'annuncio e fornisci un gestore del completamento del caricamento.
- Nel callback di completamento del caricamento, mantieni un riferimento all'annuncio caricato che viene restituito.
- Assegna un delegato che gestisca i callback di visualizzazione.
- Mostra l'annuncio.
Il nuovo approccio offre i seguenti vantaggi:
- Non avrai mai un riferimento a un annuncio non caricato.
- Non è necessario conservare un oggetto annuncio durante il caricamento.
Eventi annuncio coerenti.
Tipo di evento API esistente API v8 Eventi di caricamento GADInterstitialDelegateoGADRewardedAdDelegateGAMInterstitialAdLoadCompletionHandleroGADRewardedAdLoadCompletionHandlerEventi di presentazione GADFullScreenContentDelegateIn precedenza, per ascoltare gli eventi degli annunci, dovevi registrare una classe che implementa il protocollo
GADInterstitialDelegatein una proprietà delegata di un annuncio interstitial o registrare una classe che implementa il protocolloGADRewardedAdDelegatein una proprietà delegata di un annuncio con premio, a seconda del formato che utilizzi. Questo stesso delegato aveva metodi correlati sia al ciclo di vita di caricamento che a quello di presentazione di un annuncio.Con la versione 8, gli eventi di caricamento e presentazione sono separati. Ora puoi registrare un
GADFullScreenContentDelegatein qualsiasi momento prima di mostrare un annuncio, anziché dover impostare un singolo delegato prima di caricare l'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
Gli snippet di codice riportati di seguito mostrano come caricare un annuncio interstitial e ascoltare gli eventi quando l'annuncio viene caricato 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 di presentazione
Gli snippet di codice riportati di seguito mostrano come gestire i callback per quando l'annuncio viene presentato (con o senza esito positivo) e quando viene ignorato.
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; }
Visualizza l'annuncio display e gestisci il premio
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: nell'ambito del protocollo GADRewardedAdDelegate.
Per la versione 8, implementi 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 annuncio di 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 precedente
La più recente API GADRewardedAd è stata introdotta per la prima volta a marzo 2019 ed è l'API con premio preferita da oltre 18 mesi. Rispetto all'API GADRewardedBasedVideoAd precedente, sono stati apportati ulteriori miglioramenti, 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 dei banner intelligenti a favore dei banner adattivi
Gli annunci banner intelligenti sono stati ritirati a favore degli annunci banner adattivi. I banner adattivi offrono un rendimento superiore e una maggiore flessibilità nell'impostazione della larghezza degli annunci. Se preferisci continuare a utilizzare i banner a larghezza intera, puoi farlo utilizzando il banner adattivo, come mostrato nello snippet di codice seguente:
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
Leave application callback removal
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 abbandonano la tua app, indipendentemente dal fatto che ciò sia dovuto o meno a un'interazione con l'annuncio.
Tieni presente che il callback willLeaveApplication non è mai stato concepito per essere un gestore dei clic sugli annunci e l'utilizzo di questo callback per generare report sui clic non ha prodotto una metrica accurata. Ad esempio, un clic sull'icona Scegli Tu! che ha avviato un browser esterno ha richiamato il callback, ma non ha conteggiato un clic.
Ridenominazioni dei corsi
La tabella seguente elenca i nomi delle classi specifici che sono stati modificati o rimossi nella versione 8. In sintesi:
- Tutte le classi relative a
GADUnifiedNativeAdsono state rinominate inGADNativeAd. GADRewardBasedVideoAd,GADNativeExpressAdVieweGADInstreamAdsono stati rimossi.- Tutte le classi con il prefisso
DFPsono state sostituite con il prefissoGAM.
| 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/sostituiti
La tabella seguente elenca le modifiche specifiche della versione 8. In sintesi:
- I metodi e le proprietà precedentemente deprecati sono stati rimossi.
- I metodi delegati
-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. |
| +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 ogni richiesta. |
| gender | Rimosso | ||
| compleanno | Rimosso | ||
| +sdkVersion | GADMobileAds.sharedInstance |
||
| -setBirthday |
Rimosso | ||
| -setLocationWithDescription: | -setLocationWith |
||
| -tagForChildDirectedTreatment: | [GADMobileAds.sharedInstance.requestConfiguration tagForChildDirectedTreatment] | ||
| GADErrorCode | kGADError* | GADError* | Il prefisso k viene rimosso da tutte le costanti dei codici 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 |