Esta página aborda migrações para versões atuais e anteriores do SDK dos anúncios para dispositivos móveis do Google para iOS. A versão 12.0.0 será lançada em fevereiro de 2025.
Migrar da v11 para a v12
Fazer upgrade para o Xcode 16.0
A versão mínima do Xcode com suporte foi aumentada para 16.0.
Suporte a nomenclatura do Swift
A versão 12.0.0 inclui mudanças para seguir as convenções de nomenclatura nas Diretrizes de design da API do Swift. Essas mudanças afetam apenas o Swift. Nenhuma mudança de nomenclatura foi feita nas APIs Objective-C.
Mudanças no prefixo da classe
As seguintes mudanças foram feitas nos prefixos de classe:
- O prefixo
GAD
foi removido dos nomes de todos os tipos. - O prefixo
GAM
foi renomeado comoAdManager
. - O prefixo
GADM
foi renomeado comoMediation
.
corrigir erros.
A melhor maneira de resolver os erros resultantes dessas alterações é fazer uma correção do Fix-It.
Resolver conflitos de nomenclatura
Para resolver conflitos de nomenclatura, use o namespace fornecido pelo módulo. Por
exemplo, GADRequest
agora se chama Request
. O namespace de exemplo a seguir
é a classe Request
do SDK dos anúncios para dispositivos móveis do Google:
import GoogleMobileAds
...
var request: GoogleMobileAds.Request?
Lista detalhada de mudanças do Swift
As tabelas a seguir listam as mudanças feitas nas APIs Swift:
Versão 11 | Versão 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 |
Mediação | |
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 |
Lances em tempo real | |
GADRTBAdapter |
RTBAdapter |
GADRTBMediationSignalsConfiguration |
RTBMediationSignalsConfiguration |
GADRTBRequestParameters |
RTBRequestParameters |
Constantes
Versão 11 | Versão 12 |
---|---|
GADAdLoaderAdType.gamBanner |
AdLoaderAdType.adManagerBanner |
GADAdSizeBanner |
AdSizeBanner |
GADAdSizeFluid |
AdSizeFluid |
GADAdSizeFullBanner |
AdSizeFullBanner |
GADAdSizeInvalid |
AdSizeInvalid |
GADAdSizeLargeBanner |
AdSizeLargeBanner |
GADAdSizeLeaderboard |
AdSizeLeaderboard |
GADAdSizeMediumRectangle |
AdSizeMediumRectangle |
GADAdSizeSkyscraper |
AdSizeSkyscraper |
GoogleMobileAdsVersionString |
GoogleMobileAdsVersion |
Propriedades
Tipo | Versão 11 | Versão 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 |
Funções
Tipo | Versão 11 | Versão 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:) |
Mediação | ||
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:) |
Mudanças na API para controlar o estado de silenciamento do vídeo
A propriedade isMuted
e o método setMute:
em GADVideoController
são
substituídos por uma propriedade muted
.
Mudanças nos anúncios inline adaptativos
Para otimizar a utilização do espaço, os anúncios inline adaptáveis não ocupam espaço
no frame. Chamar CGSizeFromGADAdSize(_:)
com
um tamanho de anúncio adaptativo inline agora retorna a altura 0
até que o SDK dos anúncios para dispositivos móveis do
Google retorne um anúncio.
Anúncios personalizados de pesquisa removidos
As seguintes classes foram removidas sem substituição:
GADDynamicHeightSearchBannerView
GADDynamicHeightSearchRequest
GADSearchBannerView
Mudanças nos códigos de erro
Os seguintes códigos de erro foram alterados:
Turma | Observações |
---|---|
GADErrorMediationNoFill |
Os erros agora são retornados como GADErrorNoFill . |
GADErrorReceivedInvalidResponse |
Foi substituído por GADErrorReceivedInvalidAdString . |
GADSimulatorID removido
GADSimulatorID
foi removido. Os simuladores já estão no modo de teste por padrão.
Mudanças na segmentação personalizada
O dicionário customTargeting
em GADRequest
agora usa Any
em vez de
String
como o tipo de valor. Isso permite transmitir valores numéricos para a API.
Mudanças nos parâmetros de extras
- A transmissão de chaves para
additionalParameters
não aplica mais a segmentação personalizada às solicitações de anúncios do Ad Manager. Para aplicar a segmentação personalizada, consulte Segmentação personalizada.
- A transmissão da chave
max_ad_content_rating
paraadditionalParameters
não é mais compatível. Para definir uma classificação máxima do conteúdo do anúncio, consulte Filtragem do conteúdo do anúncio.
Migrar da v10 para a v11
Destino de implantação mínimo
O destino de implantação mínimo foi aumentado para o iOS 12.
Versão mínima do Xcode
A versão mínima do Xcode com suporte foi aumentada para 15.1.
Os anúncios param de ser veiculados no iOS 12
A versão 11.0.0 do SDK dos anúncios para dispositivos móveis do Google veicula anúncios apenas em dispositivos com iOS 13 ou mais recente.
A dependência do GoogleAppMeasurement foi removida
Na versão 11.0.0, a dependência de
GoogleAppMeasurement
foi
removida. Essa dependência que acionava a alternância de métricas do usuário na AdMob será
descontinuada no início de 2024. Para
continuar coletando métricas do usuário na AdMob,
vincule seu app da AdMob ao Firebase e
integre o
SDK do Google Analytics para Firebase ao
seu app.
Mudanças na apresentação de anúncios em tela cheia
As mudanças a seguir afetam os vários formatos de anúncio:
- Abertura do app
- Intersticial
- Premiado
- Intersticial premiado
O parâmetro do controlador de visualização em -canPresentFromRootViewController:error:
e
-presentFromRootViewController:
é anulável. Se o valor nulo for transmitido, o anúncio será
apresentado pelo controlador de visualização mais alto na hierarquia.
Métodos removidos
Os métodos a seguir foram removidos.
v11.0.0 Type | Método | Observações |
---|---|---|
GADAppOpenAd | load(withAdUnitID adUnitID: String, request: GADRequest?, orientation: UIInterfaceOrientation) |
Use load(withAdUnitID adUnitID: String, request: GADRequest?) . |
GADMediationBannerAdEventDelegate | willBackgroundApplication() |
Não há substituição. |
GADMediationInterstitialAdEventDelegate | willBackgroundApplication() |
Não há substituição. |
GADMediationNativeAdEventDelegate | willBackgroundApplication() |
Sem substituição. |
GADMediationRewardedAdEventDelegate | didRewardUser(with reward: GADAdReward) |
Use didRewardUser() . |
GADMediatedUnifiedNativeAdNotificationSource | mediatedNativeAdWillLeaveApplication(_ mediatedNativeAd: GADMediatedUnifiedNativeAd) |
Sem substituição. |
GADRequestConfiguration | setSameAppKeyEnabled(_ enabled: Bool) |
Use setPublisherFirstPartyIDEnabled(_ enabled: Bool) . |
tagForUnderAge(ofConsent underAgeOfConsent: Bool) |
Use a propriedade tagForUnderAgeOfConsent . |
|
tag(forChildDirectedTreatment childDirectedTreatment: Bool) |
Use a propriedade tagForChildDirectedTreatment . |
Propriedades removidas
As propriedades a seguir foram removidas.
Classe v11.0.0 | Propriedade | Observações |
---|---|---|
GADMediationAdConfiguration | hasUserLocation | Sem substituição. |
userLatitude | ||
userLongitude | ||
userLocationAccuracyInMeters | ||
childDirectedTreatment | Use GADMobileAds.sharedInstance.requestConfiguration.tagForChildDirectedTreatment . |
|
GADResponseInfo | adNetworkClassName | Use adNetworkClassName de loadedAdNetworkResponseInfo . |
Remoção de GADAdFormatUnknown
GADAdFormatUnknown
foi removido sem substituição.
Mudanças na versão do SDK de registro
A versão 11.0.0 remove sdkVersion
. Para registrar a versão do SDK dos anúncios para dispositivos móveis do Google,
use versionNumber
.
Versão 10.0.0
GADMobileAds.sharedInstance().sdkVersion
Versão 11.0.0
GADGetStringFromVersionNumber(GADMobileAds.sharedInstance().versionNumber)
Mudanças no tratamento de erros do GADAdLoader
A partir da versão 11.0.0, o GADAdLoader
não faz uma solicitação de anúncio se o
delegate
não estiver em conformidade com o protocolo de delegação dos tipos de anúncios solicitados. Antes, o erro ocorria
depois que a solicitação de anúncio era feita.
Mudanças no comportamento de teste
Consulte a tabela que mostra as condições atualizadas para quando as
propriedades a seguir retornam true
.
Turma | Propriedade |
---|---|
GADMediationAdConfiguration | isTestRequest |
GADCustomEventRequest | isTesting |
v10.0.0 | v11.0.0 |
|
|
Migrar da v9 para a v10
Os anúncios param de ser veiculados no iOS 11
A versão 10.0.0 do SDK dos anúncios para dispositivos móveis do Google veicula anúncios apenas em dispositivos com iOS 12 ou mais recente.
A atualização para a versão 10.0.0 do SDK dos anúncios para dispositivos móveis do Google não vai afetar seu app em dispositivos iOS 11 e iOS 10. No entanto, nenhum anúncio será veiculado nesses dispositivos.
Requisitos do ID do app do Ad Manager
O ID do app do Ad Manager agora é obrigatório em Info.plist
para todos os apps do Ad Manager e
exige o formato ca-app-pub-################~##########
. Consulte Atualizar o Info.plist
para mais detalhes.
Requisito do GoogleAppMeasurement.xcframework
O GoogleAppMeasurement.xcframework agora é obrigatório para todos os apps do Ad Manager. Se você instalar o SDK dos anúncios para dispositivos móveis do Google usando o Cocoapods ou o Swift Package Manager, não será necessário realizar nenhuma outra ação. Se você instalar os frameworks manualmente, consulte Download manual para mais detalhes.
Não há mais suporte para a criação com bitcode
Agora, é necessário desativar o bytecode nos seus apps para dispositivos móveis para integrar o SDK dos anúncios para dispositivos móveis do Google.
Tipos removidos
Tipo | Observações |
---|---|
GADGender | Sem substituição. |
GADMRewardBasedVideoAdNetworkAdapterProtocol | Todos os adaptadores de mediação com recompensa listados em Escolha as redes deixaram de usar esses protocolos há mais de um ano. Use o GADMediationAdapter para eventos personalizados e de mediação. |
GADMRewardBasedVideoAdNetworkConnectorProtocol |
Propriedades removidas
As propriedades a seguir são removidas sem substituição.
Classe v10.0.0 | Propriedade |
---|---|
GADMediationAdRequest | userBirthday |
userGender | |
userHasLocation | |
userLatitude | |
userLongitude | |
userLocationAccuracyInMeters | |
userLocationDescription | |
GADCustomEventRequest | userHasLocation |
userLatitude | |
userLongitude | |
userLocationAccuracyInMeters | |
userLocationDescription |
Migrar da v8 para a v9
Os anúncios param de ser veiculados no iOS 10
A versão mínima do iOS com suporte à versão 9.0.0 do SDK dos anúncios para dispositivos móveis do Google é o iOS 11.
A atualização para a versão 9.0.0 do SDK dos anúncios para dispositivos móveis do Google não vai afetar seu app em dispositivos iOS 10. No entanto, nenhum anúncio será veiculado nesses dispositivos.
Aplicação mais rigorosa dos controles da barra de status
A partir da versão 9.0.0, ao apresentar anúncios em tela cheia, seu app precisa garantir que eles possam controlar a apresentação da barra de status. Se você não fizer isso, uma mensagem de erro vai aparecer nos registros.
Dependendo do layout específico dos controladores de visualização no app, talvez não
seja necessário fazer nenhuma mudança para garantir isso. Verifique se você precisa definir a propriedade
childViewControllerForStatusBarHidden
no rootViewController
do seu anúncio.
O método adDidPresentFullScreenContent: foi renomeado para adWillPresentFullScreenContent:
Não há mudança de comportamento. O método delegado é invocado logo antes de o anúncio ser apresentado. Portanto, o novo nome do método reflete melhor a funcionalidade.
Remover a API Location Settings do GADRequest
- (void)setLocationWithLatitude:longitude:accuracy:
foi excluído de
GADRequest
, porque os dados de local não são usados pelo Google para segmentar anúncios. Use
APIs de terceiros para fornecer as informações às redes de publicidade de terceiros, se
necessário.
Descontinuação das interfaces de eventos personalizados
Com os eventos personalizados, os editores que usam a mediação do Ad Manager podem adicionar a mediação em hierarquia a uma rede de publicidade que não é uma das redes de publicidade com suporte.
Todos os protocolos de eventos personalizados foram descontinuados. Em vez disso, use os protocolos
GADMediationAdapter
e
GADMediationAdEventDelegate
para ter as mesmas funcionalidades. Essa mudança melhora a clareza e
permite que você crie eventos personalizados para anúncios premiados e anúncios de interscroller que
não estavam disponíveis anteriormente.
APIs
A tabela abaixo lista as APIs do adaptador de mediação correspondentes às APIs de eventos personalizados que devem ser usadas a partir da versão 9.0.0.
v8 | v9 | |
---|---|---|
GADCustomEventBanner GADCustomEventInterstitial GADCustomEventNativeAd |
GADMediationAdapter | GADMediationBannerAd GADMediationInterstitialAd GADMediationInterscrollerAd GADMediationRewardedAd GADMediationNativeAd |
delegate
|
O delegante é retornado pelo gerenciador de conclusão de carregamento de cada função de carregamento
da classe GADMediationAdapter .
|
|
-init |
-init |
|
-requestBannerAd:parameter: |
-loadBannerForAdConfiguration: |
|
-requestInterstitialAdWith |
-loadInterstitialFor |
|
-requestNativeAdWithParameter:
|
-loadNativeAdFor |
|
N/A | -loadInterscrollerAdFor |
|
N/A | -loadRewardedAdFor |
|
-presentFromRootViewController:
|
-presentFromViewController: |
|
-handlesUserClicks |
-handlesUserClicks |
|
-handlesUserImpressions |
-handlesUserImpressions |
Métodos delegados
A tabela abaixo lista os métodos de delegação de evento de anúncio de mediação correspondentes aos métodos de delegação de evento personalizado que devem ser usados a partir da versão 9.0.0.
v8 | v9 | |
---|---|---|
GADCustomEventBannerDelegate GADCustomEventInterstitialDelegate GADCustomEventNativeAdDelegate |
GADMediationAdEventDelegate | GADMediationAd |
-customEventBanner:didReceiveAd: -customEventInterstitialDidReceiveAd:
|
O status de carregamento do anúncio é incluído no gerenciador de conclusão de carregamento de
cada função de carregamento na classe GADMediationAdapter
|
|
-customEventBanner:didFailAd: -customEventInterstitial:didFailAd:
|
||
-customEventBannerWasClicked: -customEventInterstitialWasClicked:
|
-reportClick |
|
-customEventBannerWill -customEventInterstitialWill
|
-willPresentFullScreenView |
|
-customEventBannerWill -customEventInterstitialWill
|
-willDismissFullScreenView |
|
-customEventBannerDid -customEventInterstitialDid
|
-didDismissFullScreenView |
|
-customEventBannerWill -customEventInterstitialWill
|
-willBackgroundApplication |
|
viewControllerFor |
-[GADMediationBannerAd view] |
Outros métodos e constantes removidos/substituídos
Mudanças em método, constante ou propriedade | |
---|---|
Constantes com prefixo kGAD-
|
Removido. Use constantes com prefixo GAD- .
|
GADAdNetworkResponseInfo
|
credentials foram removidos. Use adUnitMapping
em vez disso.
|
GAMRequest
|
O uso de kGAMSimulatorID em GAMRequest foi descontinuado.
Use GADSimulatorID em GADRequestConfiguration .
|
GADCustomNativeAd
|
O uso de mediaView em GADCustomNativeAd foi descontinuado.
Em vez disso, use mediaContent .
|
APIs In-app purchases em GoogleMobileAds |
As APIs inAppPurchase em GoogleMobileAds foram
removidas.
|
Migrar da v7 para a v8
A versão 8.0.0 do SDK dos anúncios para dispositivos móveis do Google apresenta algumas mudanças importantes, além da mudança de nome e da remoção de APIs.
Atualizações da API de formato de tela cheia
A partir da versão 8.0.0, os anúncios intersticiais e premiados compartilham um estilo genérico de anúncios em tela cheia para maior consistência. Essas novas APIs de anúncios em tela cheia têm duas diferenças importantes em relação às APIs de anúncios em tela cheia da versão 7:
Método de classe estático
load
.A abordagem anterior para carregar/mostrar um anúncio em tela cheia é a seguinte:
- Crie uma instância do objeto de anúncio e mantenha uma referência a ela.
- Atribua um delegado que processa os callbacks de carregamento e exibição.
- Carregar um anúncio.
- Verifique se o anúncio é carregado usando
isReady
. - Mostre o anúncio.
Na versão 8, a abordagem muda um pouco. Os callbacks de carregamento não fazem mais parte de um delegado. Em vez disso, elas são transmitidas para o método
load
como um gerenciador de conclusão:- Chame um método de carregamento estático na classe de anúncio e forneça um gerenciador de conclusão de carregamento.
- No callback de conclusão de carregamento, mantenha uma referência ao anúncio carregado que é retornado.
- Atribua um delegado que processa callbacks de exibição.
- Mostre o anúncio.
A nova abordagem oferece estes benefícios:
- Você nunca terá uma referência a um anúncio que não foi carregado.
- Não é necessário manter um objeto de anúncio enquanto ele está sendo carregado.
Eventos de anúncio consistentes.
Tipo de evento API atual API v8 Eventos de carregamento GADInterstitialDelegate
ouGADRewardedAdDelegate
GAMInterstitialAdLoadCompletionHandler
ouGADRewardedAdLoadCompletionHandler
Eventos de apresentação GADFullScreenContentDelegate
Antes, para detectar qualquer evento de anúncio, você registrava uma classe que implementa o protocolo
GADInterstitialDelegate
na propriedade delegada de um intersticial ou registrava uma classe que implementa o protocoloGADRewardedAdDelegate
na propriedade delegada de um anúncio premiado, dependendo do formato que você está usando. Esse mesmo delegado tinha métodos relacionados ao ciclo de vida de carregamento e apresentação de um anúncio.Na versão 8, os eventos de carregamento e apresentação são separados. Agora é possível registrar um
GADFullScreenContentDelegate
a qualquer momento antes de mostrar um anúncio, em vez de precisar definir um único delegado antes de carregar o anúncio. Os eventos de carregamento de anúncios, que são específicos para cada formato, são movidos para um único gerenciador de conclusão de carregamento transmitido no método de carregamento.
Intersticial
Carregar anúncio
Os snippets de código abaixo mostram como carregar um anúncio intersticial e detectar eventos quando o anúncio é carregado ou não.
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; }]; }
Anúncio de display
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 anúncios de apresentação
Os snippets de código abaixo mostram como processar callbacks quando o anúncio é exibido (com ou sem sucesso) e quando ele é dispensado.
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."); }
Premiado
Carregar anúncio
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; }
Mostrar anúncios e processar recompensas
Os anúncios premiados exigem que você processe o evento quando um usuário recebe uma recompensa. Com
a versão 7 da API GADRewardedAd
, você implementa
rewardedAd:userDidEarnReward:
como parte do protocolo GADRewardedAdDelegate
.
Na versão 8, você implementa o GADUserDidEarnRewardHandler
para
apresentar o anúncio.
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 anúncios de apresentação
Com a API GADRewardedAd
, você transmite um GADRewardedAdDelegate
para o método
que apresenta o anúncio. Com a API GADRewardedAd
, você define um
GADFullscreenContentDelegate
como uma propriedade no anúncio antes de apresentá-lo.
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."); }
Remoção da API legada GADRewardedBasedVideoAd
A API
GADRewardedAd
mais recente foi lançada em março de 2019 e é a API de recompensa
preferencial há mais de 18 meses. Ela teve mais melhorias em comparação com a API GADRewardedBasedVideoAd
hereditária, incluindo a capacidade de carregar mais de um
anúncio premiado por vez.
A API GADRewardedBasedVideoAd
legada foi removida na versão 8.0.0 do SDK.
Descontinuação do banner inteligente em favor do banner adaptativo
Os anúncios de banner inteligente foram descontinuados em favor dos anúncios de banner adaptativo. Os banners adaptativos oferecem desempenho superior e mais flexibilidade na definição da largura do anúncio. Se você preferir continuar usando banners de largura total, isso ainda poderá ser feito usando banners adaptativos, conforme mostrado no snippet de código abaixo:
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
Remoção de callback de saída do aplicativo
O callback willLeaveApplication
para todos os formatos de anúncio foi
removido em favor dos métodos
applicationDidEnterBackground:
e
sceneDidEnterBackground:
. O uso de APIs no nível do SO notifica você sempre que os usuários saem do app, independentemente
de ser devido a uma interação com o anúncio ou não.
O callback willLeaveApplication
nunca foi destinado a ser
um gerenciador de cliques em anúncios, e confiar nesse callback para informar cliques não
produziu uma métrica precisa. Por exemplo, um clique no ícone da AdChoices
que inicia um navegador externo invoca o callback, mas não conta como
um clique.
Renomeação de classes
A tabela abaixo lista nomes de classes específicos que foram alterados ou removidos na versão 8. Resumindo:
- Todas as classes relacionadas a
GADUnifiedNativeAd
foram renomeadas comoGADNativeAd
. GADRewardBasedVideoAd
,GADNativeExpressAdView
eGADInstreamAd
foram removidos.- Todas as classes com o prefixo
DFP
foram substituídas por um prefixoGAM
.
v7.68.0 Class | 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 | Removido |
GADInterstitial | GADInterstitialAd |
GADNativeExpressAdView | Removido |
GADRewardBasedVideoAd | Removido |
GADInstreamAd | Removido |
GADInstreamAdView | Removido |
Métodos removidos/substituídos
A tabela abaixo lista as mudanças específicas na versão 8. Resumindo:
- Métodos e propriedades descontinuados foram removidos.
- Os métodos delegados
-willLeaveApplication:
foram removidos de todos os formatos. - O nome da classe da rede de publicidade foi movido para a propriedade
GADResponseInfo
. - O identificador do dispositivo de teste foi movido para a propriedade
GADRequestConfiguration
.
v7.68.0 Class | API v7.68.0 | API v8.0.0 | Observações |
---|---|---|---|
GADMobileAds | +configureWithApplicationID: | -startWithCompletionHandler: | O ID do app agora está definido no Info.plist. |
+disableAutomatedInApp |
-disableAutomatedInApp |
||
+disableSDKCrashReporting | -disableSDKCrashReporting | ||
GADRequest | testDevices | GADRequestConfiguration |
A propriedade testDeviceIdentifiers é aplicada a todas as solicitações de anúncio, enquanto a antiga propriedade testDevices era definida por solicitação. |
gênero | Removido | ||
aniversário | Removido | ||
+sdkVersion | GADMobileAds.sharedInstance |
||
-setBirthday |
Removido | ||
-setLocationWithDescription: | -setLocationWith |
||
-tagForChildDirectedTreatment: | [GADMobileAds.sharedInstance.requestConfiguration tagForChildDirectedTreatment] | ||
GADErrorCode | kGADError* | GADError* | O prefixo k foi removido de todas as constantes de código de erro.
|
GADBannerView | hasAutoRefreshed | autoloadEnabled | |
inAppPurchaseDelegate | Removido | ||
mediatedAdView | Removido | ||
adNetworkClassName | responseInfo |
||
DFPBannerView | -setValidAdSizesWithSizes: | -setValidAdSizes: | |
DFPBannerViewOptions | -adSizeDelegate | Removido | |
GADBannerViewDelegate | -adViewDidReceiveAd: | -bannerViewDidReceiveAd: | |
-adView:didFailToReceive |
-bannerView:didFailToReceive |
||
-adViewWillPresentScreen: | -bannerViewWillPresentScreen: | ||
-adViewWillDismissScreen: | -bannerViewWillDismissScreen: | ||
-adViewDidDismissScreen: | -bannerViewDidDismissScreen: | ||
-adViewWillLeaveApplication: | Removido | ||
GADNativeCustomTemplateAd | templateID | GADCustomNativeAd.formatID | |
-performClickOnAssetWithKey: |
-performClickOnAssetWithKey: | ||
GADNativeAdImageAd |
preferredImageOrientation | GADNativeAdMediaAdOptions |
|
GADInterstitial | inAppPurchaseDelegate | Removido | |
isReady | Removido | Use canPresentFrom |
|
hasBeenUsed | Removido | ||
-init | -initWithAdUnitID: | ||
-setAdUnitID: | -initWithAdUnitID: | ||
adNetworkClassName | responseInfo |
||
-interstitialWill |
Removido | ||
GADUnifiedNativeAd | videoController | mediaContent.videoController | |
adNetworkClassName | responseInfo |