Migration du SDK

Cette page concerne les migrations pour les versions actuelles et précédentes du SDK Google Mobile Ads pour iOS. La version 12.0.0 devrait être disponible en février 2025.

Migrer de la version 11 vers la version 12

Mettre à niveau vers Xcode 16.0

La version minimale de Xcode compatible est désormais la version 16.0.

Prise en charge de la dénomination Swift

La version 12.0.0 inclut des modifications pour respecter les conventions d'attribution de noms des consignes de conception d'API Swift. Ces modifications ne concernent que Swift. Aucune modification de dénomination n'a été apportée aux API Objective-C.

Modifications apportées au préfixe de classe

Les modifications suivantes ont été apportées aux préfixes de classe:

  • Suppression du préfixe GAD pour tous les types de noms.
  • Remplacement du préfixe GAM par AdManager.
  • Remplacement du préfixe GADM par Mediation.

Corriger les erreurs

Le meilleur moyen de résoudre les erreurs résultant de ces modifications consiste à effectuer une correction avec Fix-It.

Résoudre les conflits de dénomination

Pour résoudre les conflits de dénomination, utilisez l'espace de noms fourni par le module. Par exemple, GADRequest s'appelle désormais Request. L'exemple suivant définit des espaces de noms pour la classe Request du SDK Google Mobile Ads:

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

Liste détaillée des modifications apportées à Swift

Les tableaux suivants répertorient les modifications apportées aux API Swift:

Version 11 Version 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
Médiation
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
Enchères en temps réel
GADRTBAdapter RTBAdapter
GADRTBMediationSignalsConfiguration RTBMediationSignalsConfiguration
GADRTBRequestParameters RTBRequestParameters

Constantes

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

Propriétés

Type Version 11 Version 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

Fonctions

Type Version 11 Version 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:)
Médiation
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:)

Modifications apportées à l'API pour contrôler l'état de la mise en sourdine des vidéos

La propriété isMuted et la méthode setMute: sur GADVideoController sont remplacées par une propriété muted.

Modifications apportées aux annonces adaptatives intégrées

Pour optimiser l'utilisation de l'espace, les annonces adaptatives intégrées n'occupent initialement aucun espace dans le frame. L'appel de CGSizeFromGADAdSize(_:) avec une taille d'annonce adaptative intégrée renvoie désormais la hauteur 0 jusqu'à ce que le SDK Google Mobile Ads renvoie une annonce.

Annonces pour les recherches personnalisées supprimées

Les classes suivantes sont supprimées sans remplacement:

  • GADDynamicHeightSearchBannerView
  • GADDynamicHeightSearchRequest
  • GADSearchBannerView

Modifications apportées aux codes d'erreur

Les codes d'erreur suivants ont été modifiés:

Classe Remarques
GADErrorMediationNoFill Les erreurs sont désormais renvoyées sous la forme GADErrorNoFill.
GADErrorReceivedInvalidResponse Il a été remplacé par GADErrorReceivedInvalidAdString.

Suppression de GADSimulatorID

Suppression de GADSimulatorID. Les simulateurs sont déjà en mode test par défaut.

Modifications apportées au ciblage personnalisé

Le dictionnaire customTargeting sur GADRequest utilise désormais Any au lieu de String comme type de valeur. Cela vous permet de transmettre des valeurs numériques à l'API.

Modifications apportées aux paramètres "Extras"

  • Transmettre des clés dans additionalParameters ne permet plus d'appliquer le ciblage personnalisé aux demandes d'annonces Ad Manager. Pour appliquer un ciblage personnalisé, consultez Ciblage personnalisé.

Migrer de la version 10 vers la version 11

Cible de déploiement minimale

La version minimale de déploiement est désormais iOS 12.

Version minimale de Xcode

La version minimale de Xcode compatible est passée à la version 15.1.

Arrêt de la diffusion des annonces sur iOS 12

La version 11.0.0 du SDK Google Mobile Ads ne diffuse des annonces que sur les appareils équipés d'iOS 13 ou version ultérieure.

Suppression de la dépendance GoogleAppMeasurement

Dans la version 11.0.0, la dépendance sur GoogleAppMeasurement a été supprimée. Cette dépendance qui alimentait le bouton d'activation des métriques utilisateur dans AdMob sera abandonnée début 2024. Pour continuer à collecter des métriques utilisateur dans AdMob, associez votre application AdMob à Firebase et y intègrez le SDK Google Analytics for Firebase.

Modifications apportées à la présentation des annonces en plein écran

Les modifications suivantes concernent les différents formats d'annonces:

  • Annonce à l'ouverture
  • Interstitiel
  • Avec récompense
  • Interstitiel avec récompense

Le paramètre du contrôleur de vue dans -canPresentFromRootViewController:error: et -presentFromRootViewController: est nullable. Si la valeur nil est transmise, l'annonce est présentée à partir du contrôleur de vue le plus élevé dans la hiérarchie des contrôleurs de vue.

Méthodes supprimées

Les méthodes suivantes sont supprimées.

Type v11.0.0 Méthode Remarques
GADAppOpenAd load(withAdUnitID adUnitID: String, request: GADRequest?, orientation: UIInterfaceOrientation) Utilisez plutôt load(withAdUnitID adUnitID: String, request: GADRequest?).
GADMediationBannerAdEventDelegate willBackgroundApplication() Aucun remplacement.
GADMediationInterstitialAdEventDelegate willBackgroundApplication() Aucun remplacement.
GADMediationNativeAdEventDelegate willBackgroundApplication() Aucun remplacement.
GADMediationRewardedAdEventDelegate didRewardUser(with reward: GADAdReward) Utilisez plutôt didRewardUser().
GADMediatedUnifiedNativeAdNotificationSource mediatedNativeAdWillLeaveApplication(_ mediatedNativeAd: GADMediatedUnifiedNativeAd) Aucun remplacement.
GADRequestConfiguration setSameAppKeyEnabled(_ enabled: Bool) Utilisez setPublisherFirstPartyIDEnabled(_ enabled: Bool) à la place.
tagForUnderAge(ofConsent underAgeOfConsent: Bool) Utilisez plutôt la propriété tagForUnderAgeOfConsent.
tag(forChildDirectedTreatment childDirectedTreatment: Bool) Utilisez plutôt la propriété tagForChildDirectedTreatment.

Propriétés supprimées

Les propriétés suivantes sont supprimées.

Classe v11.0.0 Propriété Remarques
GADMediationAdConfiguration hasUserLocation Aucun remplacement.
userLatitude
userLongitude
userLocationAccuracyInMeters
childDirectedTreatment Utilisez plutôt GADMobileAds.sharedInstance.requestConfiguration.tagForChildDirectedTreatment.
GADResponseInfo adNetworkClassName Utilisez plutôt adNetworkClassName à partir de loadedAdNetworkResponseInfo.

Suppression de GADAdFormatUnknown

Suppression de GADAdFormatUnknown, sans remplacement.

Modifications apportées à la version du SDK de journalisation

La version 11.0.0 supprime sdkVersion. Pour consigner la version du SDK Google Mobile Ads, utilisez plutôt versionNumber.

Version 10.0.0

GADMobileAds.sharedInstance().sdkVersion

Version 11.0.0

GADGetStringFromVersionNumber(GADMobileAds.sharedInstance().versionNumber)

Modifications apportées à la gestion des erreurs GADAdLoader

À partir de la version 11.0.0, GADAdLoader n'effectue pas de demande d'annonce si son delegate ne respecte pas le protocole de délégué des types d'annonces demandés. Auparavant, il échouait après l'envoi de la demande d'annonce.

Modifications apportées au comportement des tests

Consultez le tableau qui indique les conditions mises à jour lorsque les propriétés suivantes renvoient true.

Classe Propriété
GADMediationAdConfiguration isTestRequest
GADCustomEventRequest isTesting
v10.0.0 v11.0.0
  • L'appareil est explicitement déclaré comme appareil de test dans testDeviceIdentifiers.
  • L'appareil est explicitement déclaré comme appareil de test dans testDeviceIdentifiers.
  • L'appareil est un simulateur.
  • L'appareil est explicitement déclaré comme appareil de test dans l'interface utilisateur d'Ad Manager.

Migrer de la version 9 vers la version 10

Arrêt de la diffusion des annonces sur iOS 11

La version 10.0.0 du SDK Google Mobile Ads ne diffuse des annonces que sur les appareils équipés d'iOS 12 ou version ultérieure.

La mise à niveau vers la version 10.0.0 du SDK Google Mobile Ads n'entraînera aucune interruption de votre application sur les appareils iOS 11 et iOS 10. Toutefois, aucune annonce ne sera diffusée sur ces appareils.

Exigences concernant l'ID d'application Ad Manager

L'ID d'application Ad Manager est désormais obligatoire dans Info.plist pour toutes les applications Ad Manager et nécessite le format ca-app-pub-################~##########. Pour en savoir plus, consultez la section Mettre à jour votre fichier Info.plist.

Exigence concernant GoogleAppMeasurement.xcframework

GoogleAppMeasurement.xcframework est désormais obligatoire pour toutes les applications Ad Manager. Si vous installez le SDK Google Mobile Ads via Cocoapods ou Swift Package Manager, aucune action supplémentaire n'est requise. Si vous installez des frameworks manuellement, consultez la section Téléchargement manuel pour en savoir plus.

La compilation avec le bitcode n'est plus prise en charge

Il est désormais obligatoire de désactiver le bitcode dans vos applications mobiles pour intégrer le SDK Google Mobile Ads.

Types supprimés

Type Remarques
GADGender Aucun remplacement.
GADMRewardBasedVideoAdNetworkAdapterProtocol Tous les adaptateurs de médiation avec récompense listés sur Choisir des réseaux ont cessé d'utiliser ces protocoles depuis plus d'un an. Utilisez GADMediationAdapter pour la médiation et les événements personnalisés.
GADMRewardBasedVideoAdNetworkConnectorProtocol

Propriétés supprimées

Les propriétés suivantes sont supprimées, sans remplacement.

Classe v10.0.0 Propriété
GADMediationAdRequest userBirthday
userGender
userHasLocation
userLatitude
userLongitude
userLocationAccuracyInMeters
userLocationDescription
GADCustomEventRequest userHasLocation
userLatitude
userLongitude
userLocationAccuracyInMeters
userLocationDescription

Migrer de la version 8 vers la version 9

Arrêt de la diffusion des annonces sur iOS 10

La version minimale d'iOS compatible avec la version 9.0.0 du SDK Google Mobile Ads est iOS 11.

La mise à niveau vers la version 9.0.0 du SDK Google Mobile Ads n'entraînera pas de problème sur votre application sur les appareils iOS 10. Toutefois, aucune annonce ne sera diffusée sur ces appareils.

Application plus stricte des commandes de la barre d'état

À partir de la version 9.0.0, lorsque vous présentez des annonces au format plein écran, votre application doit s'assurer que les annonces peuvent contrôler la présentation de la barre d'état. Si vous ne le faites pas, un message d'erreur s'affichera dans les journaux.

En fonction de la mise en page spécifique des contrôleurs de vue de votre application, vous n'aurez peut-être pas besoin d'apporter de modifications pour vous en assurer. Déterminez si vous devez définir la propriété childViewControllerForStatusBarHidden sur le rootViewController de votre annonce.

Renommez adDidPresentFullScreenContent: en adWillPresentFullScreenContent:

Le comportement ne change pas. La méthode du délégué est appelée juste avant que l'annonce ne soit présentée. Le nouveau nom de la méthode reflète donc mieux sa fonctionnalité.

Suppression de l'API des paramètres de localisation sur GADRequest

- (void)setLocationWithLatitude:longitude:accuracy: a été supprimé de GADRequest, car Google n'utilise pas les données de localisation pour cibler des annonces. Utilisez des API tierces pour fournir les informations aux réseaux publicitaires tiers, si nécessaire.

Abandon des interfaces d'événements personnalisés

Les événements personnalisés permettent aux éditeurs qui utilisent la médiation Ad Manager d'ajouter une médiation en cascade pour un réseau publicitaire qui ne fait pas partie des réseaux publicitaires compatibles.

Tous les protocoles d'événements personnalisés sont obsolètes. Utilisez plutôt les protocoles GADMediationAdapter et GADMediationAdEventDelegate existants pour obtenir les mêmes fonctionnalités. Cette modification améliore la clarté et vous permet de créer des événements personnalisés pour les annonces avec récompense et les annonces interscroller, qui n'étaient pas disponibles auparavant.

API

Le tableau ci-dessous liste les API d'adaptateur de médiation correspondant aux API d'événements personnalisés à utiliser à partir de la version 9.0.0.

v8 v9
GADCustomEventBanner
GADCustomEventInterstitial
GADCustomEventNativeAd
GADMediationAdapter GADMediationBannerAd
GADMediationInterstitialAd
GADMediationInterscrollerAd
GADMediationRewardedAd
GADMediationNativeAd
delegate Le délégué est renvoyé par le gestionnaire de fin de chargement de chaque fonction de chargement de la classe GADMediationAdapter.
-init -init
-requestBannerAd:parameter:label:request: -loadBannerForAdConfiguration:completionHandler:
-requestInterstitialAdWithParameter:label:request: -loadInterstitialForAdConfiguration:completionHandler:
-requestNativeAdWithParameter:request:adTypes:options:rootViewController: -loadNativeAdForAdConfiguration:completionHandler:
N/A -loadInterscrollerAdForAdConfiguration:completionHandler:
N/A -loadRewardedAdForAdConfiguration:completionHandler:
-presentFromRootViewController: -presentFromViewController:
-handlesUserClicks -handlesUserClicks
-handlesUserImpressions -handlesUserImpressions

Méthodes déléguées

Le tableau ci-dessous liste les méthodes de délégué d'événements publicitaires de médiation correspondantes aux méthodes de délégué d'événements personnalisées à utiliser à partir de la version 9.0.0.

v8 v9
GADCustomEventBannerDelegate
GADCustomEventInterstitialDelegate
GADCustomEventNativeAdDelegate
GADMediationAdEventDelegate GADMediationAd
-customEventBanner:didReceiveAd:
-customEventInterstitialDidReceiveAd:
L'état de chargement des annonces est inclus dans le gestionnaire de fin de chargement de chaque fonction de chargement de la classe GADMediationAdapter.
-customEventBanner:didFailAd:
-customEventInterstitial:didFailAd:
-customEventBannerWasClicked:
-customEventInterstitialWasClicked:
-reportClick
-customEventBannerWillPresentModal:
-customEventInterstitialWillPresentModal:
-willPresentFullScreenView
-customEventBannerWillDismissModal:
-customEventInterstitialWillDismissModal:
-willDismissFullScreenView
-customEventBannerDidDismissModal:
-customEventInterstitialDidDismissModal:
-didDismissFullScreenView
-customEventBannerWillLeaveApplication:
-customEventInterstitialWillLeaveApplication:
-willBackgroundApplication
viewControllerForPresentingModalView -[GADMediationBannerAd view]

Autres méthodes et constantes supprimées/remplacées

Modifications apportées à une méthode, une constante ou une propriété
Constantes avec préfixe kGAD- Supprimé. Utilisez des constantes avec le préfixe GAD-.
GADAdNetworkResponseInfo credentials ont été supprimés. Utilisez plutôt adUnitMapping.
GAMRequest kGAMSimulatorID dans GAMRequest est obsolète. Utilisez plutôt GADSimulatorID dans GADRequestConfiguration.
GADCustomNativeAd mediaView dans GADCustomNativeAd est obsolète. Utilisez plutôt mediaContent.
API d'achats via une application dans GoogleMobileAds Les API inAppPurchase de GoogleMobileAds ont été supprimées.

Migrer de la version 7 vers la version 8

La version 8.0.0 du SDK Google Mobile Ads comprend quelques modifications majeures ainsi que certains changements de nom et suppressions d'API.

Mises à jour de l'API pour le format plein écran

À partir de la version 8.0.0, les annonces interstitielles et avec récompense partagent un style d'annonce générique plein écran pour plus de cohérence. Ces nouvelles API d'annonces plein écran se distinguent par deux caractéristiques majeures par rapport aux API d'annonces plein écran de la version 7:

  1. Méthode de classe statique load.

    L'approche précédente pour charger/afficher une annonce plein écran était la suivante:

    1. Créez une instance d'objet d'annonce et conservez-en une référence.
    2. Attribuez un délégué qui gère les rappels de chargement et d'affichage.
    3. Chargez une annonce.
    4. Vérifiez si l'annonce est chargée à l'aide de isReady.
    5. Diffuser l'annonce

    Dans la version 8, l'approche change légèrement. Les rappels de chargement ne font plus partie d'un délégué. Au lieu de cela, ils sont transmis à la méthode load en tant que gestionnaire de finalisation:

    1. Appelez une méthode de chargement statique sur la classe d'annonces et fournissez un gestionnaire d'achèvement du chargement.
    2. Dans le rappel de fin de chargement, conservez une référence à l'annonce chargée qui est renvoyée.
    3. Attribuez un délégué qui gère les rappels de diffusion.
    4. Diffuser l'annonce

    Cette nouvelle approche présente les avantages suivants:

    • Vous n'aurez jamais de référence à une annonce qui n'est pas chargée.
    • Vous n'avez pas besoin de conserver un objet d'annonce pendant son chargement.
  2. Événements d'annonces cohérents

    Type d'événement API existante API v8
    Événements de chargement GADInterstitialDelegate ou GADRewardedAdDelegate GAMInterstitialAdLoadCompletionHandler ou GADRewardedAdLoadCompletionHandler
    Événements de présentation GADFullScreenContentDelegate

    Auparavant, pour écouter des événements d'annonce, vous deviez enregistrer une classe implémentant le protocole GADInterstitialDelegate à la propriété déléguée d'un interstitiel ou enregistrer une classe implémentant le protocole GADRewardedAdDelegate à la propriété déléguée d'une annonce avec récompense, en fonction du format que vous utilisez. Ce même délégué comportait des méthodes liées au cycle de vie du chargement et de la présentation d'une annonce.

    Avec la version 8, les événements de chargement et de présentation sont distincts. Vous pouvez désormais enregistrer un GADFullScreenContentDelegate à tout moment avant de diffuser une annonce au lieu d'avoir à définir un seul délégué avant de charger l'annonce. Les événements de chargement d'annonces, qui sont spécifiques à chaque format, sont déplacés vers un seul gestionnaire d'achèvement de chargement transmis dans la méthode de chargement.

Interstitiel

Charger une annonce

Les extraits de code ci-dessous vous montrent comment charger une annonce interstitielle et écouter des événements lorsque l'annonce est chargée ou non.

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;
  }];
}

Annonce 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");
  }
}

Événements d'annonce de présentation

Les extraits de code ci-dessous vous montrent comment gérer les rappels lorsque l'annonce s'affiche (avec ou sans succès) et lorsqu'elle est fermée.

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.");
}

Avec récompense

Charger une annonce

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;
}

Afficher une annonce et gérer la récompense

Les annonces avec récompense vous obligent à gérer l'événement lorsqu'un utilisateur reçoit une récompense. Avec la version 7 de l'API GADRewardedAd, vous implémentez rewardedAd:userDidEarnReward: dans le cadre du protocole GADRewardedAdDelegate. Pour la version 8, vous implémentez GADUserDidEarnRewardHandler afin de présenter l'annonce.

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");
  }
}

Événements d'annonce de présentation

Avec l'API GADRewardedAd, vous transmettez un GADRewardedAdDelegate à la méthode qui présente l'annonce. Avec l'API GADRewardedAd, vous définissez un GADFullscreenContentDelegate en tant que propriété sur l'annonce avant de la présenter.

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.");
}

Suppression de l'ancienne API GADRewardedBasedVideoAd

L'API GADRewardedAd, plus récente, a été lancée en mars 2019 et est l'API de récompense privilégiée depuis plus de 18 mois. Elle a été améliorée par rapport à l'ancienne API GADRewardedBasedVideoAd, y compris la possibilité de charger plusieurs annonces avec récompense à la fois.

L'ancienne API GADRewardedBasedVideoAd est supprimée dans la version 8.0.0 du SDK.

Abandon des bannières intelligentes au profit des bannières adaptatives

Les annonces au format bannière intelligente sont obsolètes et remplacées par les bannières adaptatives. Les bannières adaptatives offrent des performances supérieures et une plus grande flexibilité pour définir la largeur des annonces. Si vous préférez continuer à utiliser des bannières en plein écran, vous pouvez toujours le faire à l'aide d'une bannière adaptative, comme indiqué dans l'extrait de code suivant:

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

Suppression du rappel de l'application de sortie

Le rappel willLeaveApplication pour tous les formats d'annonces a été supprimé au profit des méthodes applicationDidEnterBackground: et sceneDidEnterBackground:. L'utilisation d'API au niveau de l'OS vous avertit chaque fois que les utilisateurs quittent votre application, que cela soit dû à une interaction avec une annonce ou non.

Notez que le rappel willLeaveApplication n'a jamais été conçu comme un gestionnaire de clics sur les annonces, et que s'appuyer sur ce rappel pour enregistrer les clics ne produisait pas de métrique précise. Par exemple, un clic sur l'icône AdChoices qui a lancé un navigateur externe a appelé le rappel, mais n'a pas comptabilisé de clic.

Renommage de classe

Le tableau ci-dessous liste les noms de classe spécifiques qui ont changé ou ont été supprimés dans la version 8. En résumé :

  • Toutes les classes associées à GADUnifiedNativeAd ont été renommées GADNativeAd.
  • GADRewardBasedVideoAd, GADNativeExpressAdView et GADInstreamAd ont été supprimés.
  • Toutes les classes portant le préfixe DFP ont été remplacées par un préfixe GAM.
Classe v7.68.0 Classe v8.0.0
DFPBannerView GAMBannerView
DFPBannerViewOptions GAMBannerViewOptions
DFPInterstitial GAMInterstitialAd
DFPRequest GAMRequest
GADRequestError NSError
GADUnifiedNativeAdView GADNativeAdView
GADUnifiedNativeAd GADNativeAd
GADUnifiedNativeAdAssetIdentifiers GADNativeAdAssetIdentifiers
GADUnifiedNativeAdDelegate GADNativeAdDelegate
GADUnifiedNativeAdUnconfirmedClickDelegate GADNativeAdUnconfirmedClickDelegate
GADNativeCustomTemplateAd GADCustomNativeAd
GADNativeCustomTemplateAdLoaderDelegate GADCustomNativeAdLoaderDelegate
GADNativeAdDelegate GADCustomNativeAdDelegate
GADInAppPurchase Supprimée
GADInterstitial GADInterstitialAd
GADNativeExpressAdView Supprimée
GADRewardBasedVideoAd Supprimée
GADInstreamAd Supprimée
GADInstreamAdView Supprimée

Méthodes supprimées/remplacées

Le tableau ci-dessous liste les modifications spécifiques apportées à la version 8. En résumé :

  • Les méthodes et propriétés précédemment obsolètes ont été supprimées.
  • Les méthodes de délégué -willLeaveApplication: ont été supprimées pour tous les formats.
  • Le nom de la classe du réseau publicitaire a été déplacé vers la propriété GADResponseInfo.
  • L'identifiant de l'appareil de test a été déplacé vers la propriété GADRequestConfiguration.
Classe v7.68.0 API v7.68.0 API v8.0.0 Remarques
GADMobileAds +configureWithApplicationID: -startWithCompletionHandler: L'ID de l'application est maintenant défini dans Info.plist.
+disableAutomatedInAppPurchaseReporting -disableAutomatedInAppPurchaseReporting
+disableSDKCrashReporting -disableSDKCrashReporting
GADRequest testDevices GADRequestConfiguration.testdeviceidentifiers La propriété testDeviceIdentifiers s'applique à toutes les demandes d'annonces, tandis que l'ancienne propriété testDevices était définie par requête.
gender (genre) Supprimée
birthday Supprimée
+sdkVersion GADMobileAds.sharedInstance.sdkVersion
-setBirthdayWithMonth:day:year: Supprimée
-setLocationWithDescription: -setLocationWithLatitude:longitude:accuracy:
-tagForChildDirectedTreatment: [GADMobileAds.sharedInstance.requestConfiguration tagForChildDirectedTreatment]
GADErrorCode kGADError* GADError* Le préfixe k est supprimé de toutes les constantes de code d'erreur.
GADBannerView hasAutoRefreshed autoloadEnabled
inAppPurchaseDelegate Supprimée
mediatedAdView Supprimée
adNetworkClassName responseInfo.adNetworkClassName
DFPBannerView -setValidAdSizesWithSizes: -setValidAdSizes:
DFPBannerViewOptions -adSizeDelegate Supprimée
GADBannerViewDelegate -adViewDidReceiveAd: -bannerViewDidReceiveAd:
-adView:didFailToReceiveAdWithError: -bannerView:didFailToReceiveAdWithError:
-adViewWillPresentScreen: -bannerViewWillPresentScreen:
-adViewWillDismissScreen: -bannerViewWillDismissScreen:
-adViewDidDismissScreen: -bannerViewDidDismissScreen:
-adViewWillLeaveApplication: Supprimée
GADNativeCustomTemplateAd templateID GADCustomNativeAd.formatID
-performClickOnAssetWithKey:customClickHandler: -performClickOnAssetWithKey:
GADNativeAdImageAdLoaderOptions preferredImageOrientation GADNativeAdMediaAdOptions.mediaAspectRatio
GADInterstitial inAppPurchaseDelegate Supprimée
isReady Supprimée Utilisez plutôt canPresentFromRootViewController:error:.
hasBeenUsed Supprimée
-init -initWithAdUnitID:
-setAdUnitID: -initWithAdUnitID:
adNetworkClassName responseInfo.adNetworkClassName
-interstitialWillLeaveApplication: Supprimée
GADUnifiedNativeAd videoController mediaContent.videoController
adNetworkClassName responseInfo.adNetworkClassName