En esta página, se abordan las migraciones de las versiones actuales y anteriores de Google Mobile Ads SDK para iOS. Esperamos lanzar la versión 13.0.0 en febrero de 2026.
Migra de la versión 12 a la 13
Se aumentó el objetivo de implementación mínimo
El objetivo de implementación mínimo aumentó a iOS 13.
Cambios en las APIs de tamaño de los banners adaptables fijos
La versión 13.0.0 deja de estar disponible para las APIs de tamaño de banner adaptable fijo existentes y presenta las APIs de tamaño para los anuncios de banner adaptable fijo grandes. Google Mobile Ads SDK puede publicar demanda de video en anuncios de banner con las nuevas APIs de tamaño de banner adaptable fijo grande.
En la siguiente tabla, se detallan las APIs de dimensionamiento que dejaron de estar disponibles y sus reemplazos:
| v12 (obsoleta) | v13 (reemplazo) |
|---|---|
GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADLargeAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADLandscapeAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADLargeLandscapeAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADLargePortraitAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
Compatibilidad continua con la simultaneidad de Swift 6
La versión 13.0.0 sigue agregando compatibilidad con la simultaneidad estricta de Swift 6.
Se agregó una aplicación de tipos más estricta para el array neighboringContentURLStrings.
A partir de la versión 13.0.0, Google Mobile Ads SDK genera una excepción si se detecta un objeto que no es de tipo String en el array neighboringContentURLStrings.
Migra de la versión 11 a la 12
Actualiza a Xcode 16.0
La versión mínima compatible de Xcode aumentó a la 16.0.
Compatibilidad con nombres de Swift
La versión 12.0.0 incluye cambios para seguir las convenciones de nomenclatura de los Lineamientos de diseño de la API de Swift. Estos cambios solo afectan a Swift. No se realizaron cambios en los nombres de las APIs de Objective-C.
Cambios en el prefijo de la clase
Se realizaron los siguientes cambios en los prefijos de clase:
- Se quitó el prefijo
GADen los nombres de todos los tipos. - Se cambió el nombre del prefijo
GAMporAdManager. - Se cambió el nombre del prefijo
GADMporMediation.
Resuelve los errores
La mejor manera de resolver los errores resultantes de estos cambios es hacer una corrección con Fix-It.
Cómo resolver conflictos de nombres
Para resolver los conflictos de nombres, usa el espacio de nombres que proporciona el módulo. Por
ejemplo, GADRequest ahora se llama Request. En el siguiente ejemplo, se asigna un espacio de nombres a la clase Request de Google Mobile Ads SDK:
import GoogleMobileAds
...
var request: GoogleMobileAds.Request?
Lista detallada de los cambios de Swift
En las siguientes tablas, se enumeran los cambios realizados en las APIs de Swift:
| Versión 11 | Versión 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 |
| Mediación | |
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 |
| Ofertas en tiempo real | |
GADRTBAdapter |
RTBAdapter |
GADRTBMediationSignalsConfiguration |
RTBMediationSignalsConfiguration |
GADRTBRequestParameters |
RTBRequestParameters |
Constantes
| Versión 11 | Versión 12 |
|---|---|
GADAdLoaderAdType.gamBanner |
AdLoaderAdType.adManagerBanner |
GADAdSizeBanner |
AdSizeBanner |
GADAdSizeFluid |
AdSizeFluid |
GADAdSizeFullBanner |
AdSizeFullBanner |
GADAdSizeInvalid |
AdSizeInvalid |
GADAdSizeLargeBanner |
AdSizeLargeBanner |
GADAdSizeLeaderboard |
AdSizeLeaderboard |
GADAdSizeMediumRectangle |
AdSizeMediumRectangle |
GADAdSizeSkyscraper |
AdSizeSkyscraper |
GoogleMobileAdsVersionString |
GoogleMobileAdsVersion |
Propiedades
| Tipo | Versión 11 | Versión 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 |
Funciones
| Tipo | Versión 11 | Versión 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:) |
| Mediación | ||
| 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:) |
Establece parámetros de segmentación personalizada
Para establecer la segmentación personalizada en una solicitud de anuncio, usa customTargeting.
Cambios en la API para controlar el estado de silencio de los videos
La propiedad isMuted y el método setMute: en GADVideoController se reemplazan por una propiedad muted.
Cambios en los anuncios adaptables intercalados
Para optimizar el uso del espacio, los anuncios adaptables intercalados inicialmente no ocupan espacio en el marco. Ahora, cuando se llama a CGSizeFromGADAdSize(_:) con un tamaño de anuncio adaptable intercalado, se devuelve una altura de 0 hasta que el SDK de anuncios de Google para dispositivos móviles devuelve un anuncio.
Se quitaron los anuncios de búsqueda personalizados
Se quitaron las siguientes clases sin reemplazo:
GADDynamicHeightSearchBannerViewGADDynamicHeightSearchRequestGADSearchBannerView
Cambios en los códigos de error
Se modificaron los siguientes códigos de error:
| Clase | Notas |
|---|---|
GADErrorMediationNoFill |
Ahora, los errores se devuelven como GADErrorNoFill. |
GADErrorReceivedInvalidResponse |
Se reemplazó por GADErrorReceivedInvalidAdString. |
Se quitó GADSimulatorID.
Se quitó GADSimulatorID. Los simuladores ya están en modo de prueba de forma predeterminada.
Cambios en la segmentación personalizada
El diccionario customTargeting en GADRequest ahora usa Any en lugar de String como el tipo de valor. Esto te permite pasar valores numéricos a la API.
Cambios en los parámetros de extras
- Pasar claves a
additionalParametersya no aplica la segmentación personalizada a las solicitudes de anuncios de Ad Manager. Para aplicar la segmentación personalizada, consulta Segmentación personalizada.
- Ya no se admite pasar la clave
max_ad_content_ratingaadditionalParameters. Para establecer una clasificación máxima del contenido del anuncio, consulta el filtrado de contenido de anuncios.
Migra de la versión 10 a la 11
Destino de implementación mínimo
Se aumentó el objetivo de implementación mínimo a iOS 12.
Versión mínima de Xcode
Se aumentó la versión mínima compatible de Xcode a la 15.1.
Los anuncios dejan de publicarse en iOS 12
La versión 11.0.0 del Google Mobile Ads SDK solo publica anuncios en dispositivos que ejecutan iOS 13 y versiones posteriores.
Se quitó la dependencia de GoogleAppMeasurement.
En la versión 11.0.0, se quitó la dependencia de
GoogleAppMeasurement. Esta dependencia que impulsaba el botón de activación de las métricas del usuario en AdMob se descontinuará a principios de 2024. Para
seguir recopilando métricas del usuario en AdMob,
vincula tu app de AdMob a Firebase y,
luego, integra el
SDK de Google Analytics para Firebase en
tu app.
Cambios en la presentación de anuncios de pantalla completa
Los siguientes cambios afectan a los distintos formatos de anuncios:
- Inicio de aplicación
- Intersticial
- Recompensado
- Intersticial recompensado
El parámetro del controlador de vista en -canPresentFromRootViewController:error: y -presentFromRootViewController: admite valores nulos. Si se pasa nil, el anuncio se presenta desde el controlador de vista superior en la jerarquía de controladores de vista.
Métodos quitados
Se quitaron los siguientes métodos.
| Tipo v11.0.0 | Método | Notas |
|---|---|---|
| GADAppOpenAd | load(withAdUnitID adUnitID: String, request: GADRequest?, orientation: UIInterfaceOrientation) |
En su lugar, usa load(withAdUnitID adUnitID: String, request: GADRequest?). |
| GADMediationBannerAdEventDelegate | willBackgroundApplication() |
No hay reemplazo. |
| GADMediationInterstitialAdEventDelegate | willBackgroundApplication() |
No hay reemplazo. |
| GADMediationNativeAdEventDelegate | willBackgroundApplication() |
No hay reemplazo. |
| GADMediationRewardedAdEventDelegate | didRewardUser(with reward: GADAdReward) |
En su lugar, usa didRewardUser(). |
| GADMediatedUnifiedNativeAdNotificationSource | mediatedNativeAdWillLeaveApplication(_ mediatedNativeAd: GADMediatedUnifiedNativeAd) |
No hay reemplazo. |
| GADRequestConfiguration | setSameAppKeyEnabled(_ enabled: Bool) |
Usa setPublisherFirstPartyIDEnabled(_ enabled: Bool) en su lugar. |
tagForUnderAge(ofConsent underAgeOfConsent: Bool) |
En su lugar, usa la propiedad tagForUnderAgeOfConsent. |
|
tag(forChildDirectedTreatment childDirectedTreatment: Bool) |
En su lugar, usa la propiedad tagForChildDirectedTreatment. |
Se quitaron las propiedades
Se quitaron las siguientes propiedades.
| Clase v11.0.0 | Propiedad | Notas |
|---|---|---|
| GADMediationAdConfiguration | hasUserLocation | No hay reemplazo. |
| userLatitude | ||
| userLongitude | ||
| userLocationAccuracyInMeters | ||
| childDirectedTreatment | En su lugar, usa GADMobileAds.sharedInstance.requestConfiguration.tagForChildDirectedTreatment. |
|
| GADResponseInfo | adNetworkClassName | En su lugar, usa adNetworkClassName de loadedAdNetworkResponseInfo. |
Se quitó GADAdFormatUnknown.
Se quitó GADAdFormatUnknown, pero no tiene reemplazo.
Cambios en la versión del SDK de registro
La versión 11.0.0 quita sdkVersion. Para registrar la versión de Google Mobile Ads SDK,
usa versionNumber
en su lugar.
Versión 10.0.0
GADMobileAds.sharedInstance().sdkVersion
Versión 11.0.0
GADGetStringFromVersionNumber(GADMobileAds.sharedInstance().versionNumber)
Cambios en el manejo de errores de GADAdLoader
A partir de la versión 11.0.0, GADAdLoader no realiza una solicitud de anuncio si su delegate no cumple con el protocolo delegado de los tipos de anuncios solicitados. Anteriormente, fallaba después de que se realizaba la solicitud de anuncio.
Cambios en el comportamiento de las pruebas
Consulta la tabla que muestra las condiciones actualizadas para cuando las siguientes propiedades devuelven true.
| Clase | Propiedad |
|---|---|
| GADMediationAdConfiguration | isTestRequest |
| GADCustomEventRequest | isTesting |
| v10.0.0 | v11.0.0 |
|
|
Migra de la versión 9 a la 10
Los anuncios dejan de publicarse en iOS 11
La versión 10.0.0 de Google Mobile Ads SDK publica anuncios solo en dispositivos que ejecutan iOS 12 y versiones posteriores.
Actualizar a la versión 10.0.0 de Google Mobile Ads SDK no afectará el funcionamiento de tu app en dispositivos con iOS 11 y iOS 10, pero no se publicarán anuncios en ellos.
Requisito del ID de app de Ad Manager
Ahora, el ID de app de Ad Manager es obligatorio en Info.plist para todas las apps de Ad Manager y requiere el formato ca-app-pub-################~##########. Consulta Actualiza tu archivo Info.plist para obtener más detalles.
Requisito de GoogleAppMeasurement.xcframework
Ahora, GoogleAppMeasurement.xcframework es obligatorio para todas las apps de Ad Manager. Si instalas Google Mobile Ads SDK a través de Cocoapods o Swift Package Manager, no se requiere ninguna acción adicional. Si instalas frameworks de forma manual, consulta Descarga manual para obtener más detalles.
Ya no se admite la compilación con bitcode
Ahora, para integrar el Google Mobile Ads SDK, es obligatorio inhabilitar el código de bits en tus apps para dispositivos móviles.
Se quitaron los tipos
| Tipo | Notas |
|---|---|
| GADGender | No hay reemplazo. |
| GADMRewardBasedVideoAdNetworkAdapterProtocol | Todos los adaptadores de mediación de anuncios recompensados que se indican en Elige redes dejaron de usar estos protocolos hace más de un año. Usa GADMediationAdapter para la mediación y los eventos personalizados. |
| GADMRewardBasedVideoAdNetworkConnectorProtocol |
Se quitaron las propiedades
Se quitaron las siguientes propiedades sin reemplazo.
| Clase v10.0.0 | Propiedad |
|---|---|
| GADMediationAdRequest | userBirthday |
| userGender | |
| userHasLocation | |
| userLatitude | |
| userLongitude | |
| userLocationAccuracyInMeters | |
| userLocationDescription | |
| GADCustomEventRequest | userHasLocation |
| userLatitude | |
| userLongitude | |
| userLocationAccuracyInMeters | |
| userLocationDescription |
Migra de la versión 8 a la 9
Los anuncios dejan de publicarse en iOS 10
La versión mínima de iOS que admite la versión 9.0.0 de Google Mobile Ads SDK es iOS 11.
Actualizar a la versión 9.0.0 de Google Mobile Ads SDK no afectará tu app en dispositivos con iOS 10, pero no se publicarán anuncios en esos dispositivos.
Aplicación más estricta de los controles de la barra de estado
A partir de la versión 9.0.0, cuando presentes anuncios en formato de pantalla completa, tu app debe asegurarse de que los anuncios puedan controlar la presentación de la barra de estado. Si no lo haces, verás un mensaje de error en los registros.
Según el diseño específico de los controladores de vista de tu app, es posible que no necesites realizar ningún cambio para garantizar esto. Considera si necesitas establecer la propiedad childViewControllerForStatusBarHidden en el rootViewController de tu anuncio.
Cambia el nombre de adDidPresentFullScreenContent: a adWillPresentFullScreenContent:
No hay cambios en el comportamiento. Se invoca el método delegado justo antes de que se presente el anuncio, por lo que el nuevo nombre del método refleja mejor su funcionalidad.
Se quitó la API de configuración de ubicación en GADRequest.
Se borró - (void)setLocationWithLatitude:longitude:accuracy: de
GADRequest, ya que Google no usa los datos de ubicación para segmentar anuncios. Usa APIs de terceros para proporcionar la información a las redes de publicidad de terceros si es necesario.
Baja de las interfaces de eventos personalizados
Los eventos personalizados permiten que los publicadores que usan la Mediación de Ad Manager agreguen la mediación en cascada para una red de publicidad que no sea una de las redes de publicidad admitidas.
Todos los protocolos de eventos personalizados están obsoletos. En su lugar, usa los protocolos existentes
GADMediationAdapter
y
GADMediationAdEventDelegate
para lograr las mismas funcionalidades. Este cambio mejora la claridad y te permite crear eventos personalizados para los anuncios recompensados y los anuncios interscroller, que antes no estaban disponibles.
API
En la siguiente tabla, se enumeran las APIs de adaptadores de mediación correspondientes a las APIs de eventos personalizados que se deben usar a partir de la versión 9.0.0.
| v8 | v9 | |
|---|---|---|
| GADCustomEventBanner GADCustomEventInterstitial GADCustomEventNativeAd |
GADMediationAdapter | GADMediationBannerAd GADMediationInterstitialAd GADMediationInterscrollerAd GADMediationRewardedAd GADMediationNativeAd |
delegate
|
El controlador de finalización de carga de cada función de carga de la clase GADMediationAdapter devuelve el delegado.
|
|
-init |
-init |
|
-requestBannerAd:parameter: |
-loadBannerForAdConfiguration: |
|
-requestInterstitialAdWith |
-loadInterstitialFor |
|
-requestNativeAdWithParameter:
|
-loadNativeAdFor |
|
| N/A | -loadInterscrollerAdFor |
|
| N/A | -loadRewardedAdFor |
|
-presentFromRootViewController:
|
-presentFromViewController: |
|
-handlesUserClicks |
-handlesUserClicks |
|
-handlesUserImpressions |
-handlesUserImpressions |
|
Métodos de delegado
En la siguiente tabla, se enumeran los métodos de delegado de eventos de anuncios de mediación correspondientes a los métodos de delegado de eventos personalizados que se deben usar a partir de la versión 9.0.0.
| v8 | v9 | |
|---|---|---|
| GADCustomEventBannerDelegate GADCustomEventInterstitialDelegate GADCustomEventNativeAdDelegate |
GADMediationAdEventDelegate | GADMediationAd |
-customEventBanner:didReceiveAd:-customEventInterstitialDidReceiveAd:
|
El estado de carga del anuncio se incluye en el controlador de finalización de carga de cada función de carga de la clase GADMediationAdapter.
|
|
-customEventBanner:didFailAd:-customEventInterstitial:didFailAd:
|
||
-customEventBannerWasClicked:-customEventInterstitialWasClicked:
|
-reportClick |
|
-customEventBannerWill-customEventInterstitialWill
|
-willPresentFullScreenView |
|
-customEventBannerWill-customEventInterstitialWill
|
-willDismissFullScreenView |
|
-customEventBannerDid-customEventInterstitialDid
|
-didDismissFullScreenView |
|
-customEventBannerWill-customEventInterstitialWill
|
-willBackgroundApplication |
|
viewControllerFor |
-[GADMediationBannerAd view] |
|
Otros métodos y constantes que se quitaron o reemplazaron
| Cambios en un método, una constante o una propiedad | |
|---|---|
Constantes con el prefijo kGAD-
|
Se quitó el elemento. Usa constantes con el prefijo GAD-.
|
GADAdNetworkResponseInfo
|
Se quitaron credentials. Usa adUnitMapping en su lugar.
|
GAMRequest
|
kGAMSimulatorID en GAMRequest dejó de estar disponible.
En su lugar, usa GADSimulatorID en GADRequestConfiguration.
|
GADCustomNativeAd
|
mediaView en GADCustomNativeAd dejó de estar disponible.
Utiliza mediaContent en lugar de esta función.
|
APIs de compras directas desde la app en GoogleMobileAds |
Se quitaron las APIs de inAppPurchase en GoogleMobileAds.
|
Migra de la versión 7 a la 8
La versión 8.0.0 de Google Mobile Ads SDK presenta algunos cambios importantes, así como algunos cambios de nombre y eliminaciones de APIs.
Actualizaciones de la API de formatos de pantalla completa
A partir de la versión 8.0.0, los anuncios intersticiales y los anuncios recompensados comparten un estilo de anuncio de pantalla completa genérico para lograr una mayor coherencia. Estas nuevas APIs de anuncios de pantalla completa tienen dos diferencias importantes con respecto a las APIs de anuncios de pantalla completa de la versión 7:
Método de clase estático
load.El enfoque anterior para cargar o mostrar un anuncio de pantalla completa es el siguiente:
- Crea una instancia de objeto de anuncio y conserva una referencia a ella.
- Asigna un delegado que controle las devoluciones de llamada de carga y visualización.
- Carga un anuncio.
- Verifica si el anuncio se cargó con
isReady. - Muestra el anuncio.
En la versión 8, el enfoque cambia un poco. Las devoluciones de llamada de carga ya no forman parte de un delegado. En su lugar, se pasan al método
loadcomo un controlador de finalización:- Llama a un método de carga estático en la clase del anuncio y proporciona un controlador de finalización de carga.
- En la devolución de llamada de finalización de carga, conserva una referencia al anuncio cargado que se devuelve.
- Asigna un delegado que controle las devoluciones de llamada de presentación.
- Muestra el anuncio.
El nuevo enfoque proporciona los siguientes beneficios:
- Nunca tendrás una referencia a un anuncio que no se haya cargado.
- No es necesario que conserves un objeto de anuncio mientras se carga.
Eventos de anuncios coherentes
Tipo de evento API existente API v8 Eventos de carga GADInterstitialDelegateoGADRewardedAdDelegateGAMInterstitialAdLoadCompletionHandleroGADRewardedAdLoadCompletionHandlerEventos de presentación GADFullScreenContentDelegateAnteriormente, para escuchar cualquier evento de anuncio, debías registrar una clase que implementara el protocolo
GADInterstitialDelegateen la propiedad de delegado de un anuncio intersticial o una clase que implementara el protocoloGADRewardedAdDelegateen la propiedad de delegado de un anuncio recompensado, según el formato que usaras. Este mismo delegado tenía métodos relacionados con el ciclo de vida de carga y presentación de un anuncio.En la versión 8, los eventos de carga y presentación son independientes. Ahora puedes registrar un
GADFullScreenContentDelegateen cualquier momento antes de mostrar un anuncio, en lugar de tener que establecer un solo delegado antes de cargarlo. Los eventos de carga de anuncios, que son específicos de cada formato, se mueven a un único controlador de finalización de carga que se pasa en el método de carga.
Intersticial
Carga el anuncio
En los siguientes fragmentos de código, se muestra cómo cargar un anuncio intersticial y escuchar eventos cuando el anuncio se carga correctamente o no.
v7
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; }]; }
Anuncio gráfico
v7
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"); } }
Eventos de anuncios de presentación
En los siguientes fragmentos de código, se muestra cómo controlar las devoluciones de llamada cuando el anuncio se presenta (correctamente o con errores) y cuando se descarta.
v7
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."); }
Recompensado
Carga el anuncio
v7
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; }
Muestra el anuncio gráfico y controla la recompensa
Los anuncios recompensados requieren que controles el evento cuando un usuario obtiene una recompensa. Con
la versión 7 de la API de GADRewardedAd, implementas
rewardedAd:userDidEarnReward: como parte del protocolo GADRewardedAdDelegate.
En la versión 8, implementas GADUserDidEarnRewardHandler para presentar el anuncio.
v7
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"); } }
Eventos de anuncios de presentación
Con la API de GADRewardedAd, pasas un objeto GADRewardedAdDelegate al método que presenta el anuncio. Con la API de GADRewardedAd, estableces un GADFullscreenContentDelegate como propiedad del anuncio antes de presentarlo.
v7
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."); }
Eliminación de la API de GADRewardedBasedVideoAd heredada
La API de GADRewardedAd más reciente se introdujo por primera vez en marzo de 2019 y ha sido la API de recompensas preferida durante más de 18 meses. Tiene más mejoras en comparación con la API de GADRewardedBasedVideoAd heredada, incluida la capacidad de cargar más de un anuncio recompensado a la vez.
La API de GADRewardedBasedVideoAd heredada se quitará en la versión 8.0.0 del SDK.
Banners inteligentes descontinuados en favor de los banners adaptables
Los anuncios de banner inteligente dejaron de estar disponibles y se reemplazaron por los anuncios de banner adaptable. Los banners adaptables proporcionan un rendimiento superior y más flexibilidad para establecer el ancho de los anuncios. Si prefieres seguir usando banners de ancho completo, puedes hacerlo con un banner adaptable, como se muestra en el siguiente fragmento de código:
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
Eliminación de la devolución de llamada de salida de la aplicación
Se quitó la devolución de llamada willLeaveApplication para todos los formatos de anuncios y se reemplazó por los métodos applicationDidEnterBackground: y sceneDidEnterBackground:. El uso de las APIs a nivel del SO te notifica cada vez que los usuarios abandonan tu app, independientemente de si se debe o no a una interacción con un anuncio.
Ten en cuenta que la devolución de llamada willLeaveApplication nunca se diseñó para ser un controlador de clics en el anuncio, y depender de esta devolución de llamada para informar los clics no produjo una métrica precisa. Por ejemplo, un clic en el ícono de AdChoices que inició un navegador externo invocó la devolución de llamada, pero no contó un clic.
Cambios de nombre de clases
En la siguiente tabla, se enumeran los nombres de clases específicos que se cambiaron o quitaron en la versión 8. Resumen:
- Se cambió el nombre de todas las clases relacionadas con
GADUnifiedNativeAdporGADNativeAd. - Se quitaron
GADRewardBasedVideoAd,GADNativeExpressAdViewyGADInstreamAd. - Todas las clases con el prefijo
DFPse reemplazaron por el prefijoGAM.
| Clase v7.68.0 | Clase 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 | Quitada |
| GADInterstitial | GADInterstitialAd |
| GADNativeExpressAdView | Quitada |
| GADRewardBasedVideoAd | Quitada |
| GADInstreamAd | Quitada |
| GADInstreamAdView | Quitada |
Se quitaron o reemplazaron métodos
En la siguiente tabla, se enumeran los cambios específicos de la versión 8. Resumen:
- Se quitaron los métodos y las propiedades que anteriormente habían quedado obsoletos.
- Se quitaron los métodos delegados de
-willLeaveApplication:para todos los formatos. - El nombre de la clase de la red de publicidad se movió a la propiedad
GADResponseInfo. - El identificador del dispositivo de prueba se movió a la propiedad
GADRequestConfiguration.
| Clase v7.68.0 | API v7.68.0 | API v8.0.0 | Notas |
|---|---|---|---|
| GADMobileAds | +configureWithApplicationID: | -startWithCompletionHandler: | El ID de la app ahora está configurado en Info.plist. |
| +disableAutomatedInApp |
-disableAutomatedInApp |
||
| +disableSDKCrashReporting | -disableSDKCrashReporting | ||
| GADRequest | testDevices | GADRequestConfiguration |
La propiedad testDeviceIdentifiers se aplica a todas las solicitudes de anuncios, mientras que la propiedad testDevices anterior se configuraba por solicitud. |
| género | Quitada | ||
| birthday | Quitada | ||
| +sdkVersion | GADMobileAds.sharedInstance |
||
| -setBirthday |
Quitada | ||
| -setLocationWithDescription: | -setLocationWith |
||
| -tagForChildDirectedTreatment: | [GADMobileAds.sharedInstance.requestConfiguration tagForChildDirectedTreatment] | ||
| GADErrorCode | kGADError* | GADError* | Se quita el prefijo k de todas las constantes de código de error.
|
| GADBannerView | hasAutoRefreshed | autoloadEnabled | |
| inAppPurchaseDelegate | Quitada | ||
| mediatedAdView | Quitada | ||
| adNetworkClassName | responseInfo |
||
| DFPBannerView | -setValidAdSizesWithSizes: | -setValidAdSizes: | |
| DFPBannerViewOptions | -adSizeDelegate | Quitada | |
| GADBannerViewDelegate | -adViewDidReceiveAd: | -bannerViewDidReceiveAd: | |
| -adView:didFailToReceive |
-bannerView:didFailToReceive |
||
| -adViewWillPresentScreen: | -bannerViewWillPresentScreen: | ||
| -adViewWillDismissScreen: | -bannerViewWillDismissScreen: | ||
| -adViewDidDismissScreen: | -bannerViewDidDismissScreen: | ||
| -adViewWillLeaveApplication: | Quitada | ||
| GADNativeCustomTemplateAd | templateID | GADCustomNativeAd.formatID | |
| -performClickOnAssetWithKey: |
-performClickOnAssetWithKey: | ||
| GADNativeAdImageAd |
preferredImageOrientation | GADNativeAdMediaAdOptions |
|
| GADInterstitial | inAppPurchaseDelegate | Quitada | |
| isReady | Quitada | En su lugar, usa canPresentFrom |
|
| hasBeenUsed | Quitada | ||
| -init | -initWithAdUnitID: | ||
| -setAdUnitID: | -initWithAdUnitID: | ||
| adNetworkClassName | responseInfo |
||
| -interstitialWill |
Quitada | ||
| GADUnifiedNativeAd | videoController | mediaContent.videoController | |
| adNetworkClassName | responseInfo |