Migration du SDK

Cette page traite des migrations pour les versions actuelles et précédentes du SDK Google Mobile Ads pour iOS. La version 12.0.0 devrait sortir en février 2025.

Migrer de la version 11 à la version 12 du SDK

Mettre à niveau vers Xcode 16.0

La version minimale d'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 visant à respecter les conventions de dénomination des consignes de conception d'API Swift. Ces modifications n'affectent que Swift. Aucun changement de nom n'a été apporté aux API Objective-C.

Modifications du préfixe de classe

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

  • Le préfixe GAD a été supprimé des noms de tous les types.
  • Le préfixe GAM a été renommé AdManager.
  • Le préfixe GADM a été renommé Mediation.

Corriger les erreurs

La meilleure façon de résoudre les erreurs résultant de ces modifications consiste à effectuer une correction Fix-It.

Résoudre les conflits de noms

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

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

Liste détaillée des modifications Swift

Les tableaux suivants listent 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 une hauteur de 0 jusqu'à ce que le SDK Google Mobile Ads renvoie une annonce.

Suppression des annonces pour les recherches personnalisé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 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 des extras

Migrer de la version 10 vers la version 11

Cible de déploiement minimale

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

Version minimale d'Xcode

La version minimale d'Xcode compatible est désormais la version 15.1.

Les annonces ne sont plus diffusées sur iOS 12

Le SDK Google Mobile Ads version 11.0.0 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 arrêtée début 2024. Pour continuer à collecter des métriques utilisateur dans AdMob, associez votre application AdMob à Firebase et intégrez le SDK Google Analytics for Firebase dans votre application.

Modifications apportées à la présentation des annonces 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 haut dans la hiérarchie des contrôleurs de vue.

Méthodes supprimées

Les méthodes suivantes ont été 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 depuis 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 enregistrer 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 de GADAdLoader

À partir de la version 11.0.0, GADAdLoader n'envoie pas de demande d'annonce si son delegate ne respecte pas le protocole de délégation des types d'annonces demandés. Auparavant, l'échec se produisait après l'envoi de la demande d'annonce.

Modifications apportées au comportement de test

Consultez le tableau qui indique les conditions mises à jour pour lesquelles 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'UI AdMob.

Migrer de la version 9 vers la version 10

Les annonces ne sont plus diffusées sur iOS 11

Le SDK Google Mobile Ads version 10.0.0 ne diffuse des annonces que sur les appareils exécutant iOS 12 ou version ultérieure.

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

La création avec bitcode n'est plus acceptée

Vous devez désormais 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 d'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'aura aucune incidence sur votre application sur les appareils iOS 10. Toutefois, aucune annonce ne sera diffusée sur ces appareils.

Application plus stricte des contrôles 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.

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

Renommez adDidPresentFullScreenContent: en adWillPresentFullScreenContent:

Le comportement reste inchangé. La méthode du délégué est appelée juste avant la présentation de l'annonce. Le nouveau nom de la méthode reflète donc mieux sa fonctionnalité.

Supprimer l'API de paramètre 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 les annonces. Utilisez des API tierces pour fournir les informations aux réseaux publicitaires tiers, si nécessaire.

Arrêt des interfaces d'événements personnalisés

Les événements personnalisés permettent aux éditeurs qui utilisent la médiation AdMob d'ajouter la 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 existants GADMediationAdapter et GADMediationAdEventDelegate 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, ce qui n'était pas possible auparavant.

API

Le tableau ci-dessous liste les API d'adaptateur de médiation correspondantes 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 d'achèvement du 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 de délégation

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

v8 v9
GADCustomEventBannerDelegate
GADCustomEventInterstitialDelegate
GADCustomEventNativeAdDelegate
GADMediationAdEventDelegate GADMediationAd
-customEventBanner:didReceiveAd:
-customEventInterstitialDidReceiveAd:
L'état de la charge publicitaire est inclus dans le gestionnaire d'achèvement de la charge 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 préfixées kGAD- Supprimé. Utilisez des constantes préfixées par GAD-.
GADAdNetworkResponseInfo credentials ont été supprimés. Utilisez plutôt adUnitMapping.
GADCustomNativeAd mediaView dans GADCustomNativeAd est obsolète. Utilisez plutôt mediaContent.
API d'achats via une application dans GoogleMobileAds Les API inAppPurchase dans 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 plein écran générique pour plus de cohérence. Ces nouvelles API d'annonces plein écran se distinguent de deux manières principales des API d'annonces plein écran de la version 7 :

  1. Méthode de classe statique load.

    L'ancienne approche pour charger/afficher une annonce en plein écran est la suivante :

    1. Créez une instance d'objet d'annonce et conservez-y 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é. Elles sont plutôt transmises à la méthode load en tant que gestionnaire d'achèvement :

    1. Appelez une méthode de chargement statique sur la classe d'annonce et fournissez un gestionnaire d'achèvement du chargement.
    2. Dans le rappel d'achèvement du 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 d'affichage.
    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 GADInterstitialAdLoadCompletionHandler ou GADRewardedAdLoadCompletionHandler
    Événements de présentation GADFullScreenContentDelegate

    Auparavant, pour écouter les événements d'annonce, vous deviez enregistrer une classe qui implémente le protocole GADInterstitialDelegate dans la propriété déléguée d'un interstitiel, ou enregistrer une classe qui implémente le protocole GADRewardedAdDelegate dans la propriété déléguée d'une annonce avec récompense, selon le format que vous utilisiez. 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.

    Dans la version 8, les événements de chargement et de présentation sont distincts. Vous pouvez désormais enregistrer un GADFullScreenContentDelegate à tout moment avant d'afficher une annonce, au lieu d'être obligé de 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 gestionnaire d'achèvement de chargement unique transmis dans la méthode de chargement.

Interstitiel

Charger l'annonce

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

v7

Swift

import GoogleMobileAds
import UIKit

class ViewController: UIViewController, GADInterstitialDelegate {

  var interstitial: GADInterstitial!

  override func viewDidLoad() {
    super.viewDidLoad()
    interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/4411468910")
    interstitial.delegate = self
    let request = GADRequest()
    interstitial.load(request)
  }

  /// Tells the delegate an ad request succeeded.
  func interstitialDidReceiveAd(_ ad: GADInterstitial) {
    print("Interstitial ad loaded.")
  }

  /// Tells the delegate an ad request failed.
  func interstitial(_ ad: GADInterstitial, didFailToReceiveAdWithError error: GADRequestError) {
    print("Interstitial ad failed to load with error: \(error.localizedDescription)")
  }
}

Objective-C

@import GoogleMobileAds;
@import UIKit;

@interface ViewController () 

@property(nonatomic, strong) GADInterstitial *interstitial;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];
  self.interstitial = [[GADInterstitial alloc]
      initWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910"];
  self.interstitial.delegate = self;
  GADRequest *request = [GADRequest request];
  [self.interstitial loadRequest:request];
}

/// Tells the delegate an ad request succeeded.
- (void)interstitialDidReceiveAd:(GADInterstitial *)ad {
  NSLog(@"Insterstitial ad loaded.");
}

/// Tells the delegate an ad request failed.
- (void)interstitial:(GADInterstitial *)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: GADInterstitialAd?

  override func viewDidLoad() {
    super.viewDidLoad()
    let request = GADRequest()
    GADInterstitialAd.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) GADInterstitialAd *interstitial;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];
  GADRequest *request = [GADRequest request];
  [GADInterstitialAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910"
                              request:request
                    completionHandler:^(GADInterstitialAd *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 est présentée (avec ou sans succès) et lorsqu'elle est fermée.

v7

Swift

override func viewDidLoad() {
  super.viewDidLoad()
  interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/4411468910")
  interstitial.delegate = self
  ...
}

/// Tells the delegate that an interstitial will be presented.
func interstitialWillPresentScreen(_ ad: GADInterstitial) {
  print("Interstitial ad will be presented.")
}

/// Tells the delegate the interstitial is to be animated off the screen.
func interstitialWillDismissScreen(_ ad: GADInterstitial) {
  print("Interstitial ad will be dismissed.")
}

/// Tells the delegate the interstitial had been animated off the screen.
func interstitialDidDismissScreen(_ ad: GADInterstitial) {
  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: GADInterstitial) {
  print("Interstitial ad will leave application.")
}

Objective-C

- (void)viewDidLoad {
  [super viewDidLoad];
  self.interstitial = [[GADInterstitial alloc] initWithAdUnitID:"ca-app-pub-3940256099942544/4411468910"];
  self.interstitial.delegate = self;
  ...
}

/// Tells the delegate that an interstitial will be presented.
- (void)interstitialWillPresentScreen:(GADInterstitial *)ad {
  NSLog(@"Interstitial ad will be presented.");
}

/// Tells the delegate the interstitial is to be animated off the screen.
- (void)interstitialWillDismissScreen:(GADInterstitial *)ad {
  NSLog(@"Interstitial ad will be dismissed.");
}

/// Tells the delegate the interstitial had been animated off the screen.
- (void)interstitialDidDismissScreen:(GADInterstitial *)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:(GADInterstitial *)ad {
  NSLog(@"Interstitial ad will leave application.");
}

v8

Swift

override func viewDidLoad() {
  super.viewDidLoad()
  let request = GADRequest()
  GADInterstitialAd.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];
  GADRequest *request = [GADRequest request];
  [GADInterstitialAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910"
                              request:request
                    completionHandler:^(GADInterstitialAd *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 l'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(GADRequest()) { 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;
  GADRequest *request = [GADRequest 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 = GADRequest()
  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];

  GADRequest *request = [GADRequest 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;
}

Annonce display et gestion de la récompense

Les annonces avec récompense vous obligent à gérer l'événement lorsqu'un utilisateur gagne une récompense. Avec la version 7 de l'API GADRewardedAd, vous implémentez rewardedAd:userDidEarnReward: dans le 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 comme propriété de 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 = GADRequest()
  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];

  GADRequest *request = [GADRequest 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

La nouvelle API GADRewardedAd a été lancée en mars 2019 et est l'API de récompense privilégiée depuis plus de 18 mois. Elle a bénéficié de plus d'améliorations que 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.

Arrêt des bannières intelligentes au profit des bannières adaptatives

Les annonces Bannière intelligente sont obsolètes et remplacées par les annonces Bannière adaptative. Les bannières adaptatives offrent de meilleures performances et plus de flexibilité pour définir la largeur des annonces. Si vous préférez continuer à utiliser des bannières pleine largeur, vous pouvez toujours le faire à l'aide de bannières adaptatives, 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 sortie de l'application

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

Notez que le rappel willLeaveApplication n'a jamais été conçu pour être un gestionnaire de clics sur les annonces. S'appuyer sur ce rappel pour signaler les clics ne produisait pas de métrique précise. Par exemple, un clic sur l'icône "Choix de pub" qui a lancé un navigateur externe a invoqué le rappel, mais n'a pas comptabilisé de clic.

Renommer des cours

Le tableau ci-dessous liste les noms de classes spécifiques qui ont été modifiés ou 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 demande.
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