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 exécutant 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 disponible

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 comporte quelques modifications majeures, ainsi que renommage et suppression 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 pour plus de cohérence. Ces nouvelles API d'annonces plein écran offrent différences majeures par rapport aux API d'annonces plein écran version 7:

  1. Méthode de classe statique load.

    L'approche précédente pour charger/diffuser une annonce en plein écran est la suivante:

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

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

    1. Appeler une méthode de chargement statique sur la classe d'annonce et indiquer la fin du chargement .
    2. Dans le rappel de fin de chargement, conservez une référence à l'annonce chargée renvoyé.
    3. Attribuez un délégué qui gère les rappels d'affichage.
    4. Diffusez l'annonce.

    Cette nouvelle approche offre les avantages suivants:

    • Vous ne disposerez jamais d'une référence à une annonce non chargée.
    • Vous n'avez pas besoin de conserver un objet d'annonce pendant son chargement.
  2. Des événements publicitaires 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 les événements d'annonce, vous deviez enregistrer une classe met en œuvre GADInterstitialDelegate à la propriété déléguée d'un interstitiel ou enregistrez une classe qui met en œuvre GADRewardedAdDelegate à la propriété déléguée d'une annonce avec récompense, selon le format que vous utilisez. Ce même délégué avait des méthodes liées au chargement et du cycle de vie de la présentation d'une annonce.

    Dans la version 8, les événements de chargement et de présentation sont distincts. Vous pouvez maintenant enregistrer un GADFullScreenContentDelegate avant la diffusion d'une annonce, au lieu de devoir définir une seule délégué avant de charger l'annonce. Les événements de chargement d'annonces, qui sont spécifiques à chaque utilisez un seul gestionnaire d'achèvement de chargement transmis à la méthode de chargement.

Interstitiel

Charger l'annonce

Les extraits de code ci-dessous vous montrent comment charger une annonce interstitielle et écouter lorsque le chargement de l'annonce réussit ou échoue.

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 de l'annonce de présentation

Les extraits de code ci-dessous vous montrent comment gérer les rappels lorsque l'annonce présente (réussie ou non) et lorsqu'elle est ignoré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 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(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;
}

Annonce display et gestion de la récompense

Avec les annonces avec récompense, vous devez gérer l'événement lorsqu'un utilisateur gagne une récompense. Avec version 7 de l'API GADRewardedAd, vous implémentez rewardedAd:userDidEarnReward: dans le cadre du protocole GADRewardedAdDelegate. Pour la version 8, implémentez GADUserDidEarnRewardHandler afin d'effectuer les opérations suivantes : 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 de l'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 présenter la 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 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 GADRewardBasedVideoAd

Les plus récents GADRewardedAd L'API a été introduite en mars 2019 et a été l'API privilégiée depuis plus de 18 mois. Elle a fait l'objet de plus d'améliorations par rapport à la version précédente L'API GADRewardedBasedVideoAd, y compris la possibilité d'en charger plusieurs annonce avec récompense à la fois.

L'ancienne API GADRewardedBasedVideoAd a été supprimée de la version 8.0.0 du SDK.

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

Les bannières intelligentes sont obsolètes en faveur des bannières adaptatives annonces. Les bannières adaptatives offrent des performances supérieures et davantage de flexibilité pour définir la largeur de l'annonce. Si vous préférez continuer à utiliser des bannières pleine largeur, vous pouvez utiliser une bannière adaptative, comme illustré 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

Quitter la suppression du rappel d'application

Pour tous les formats d'annonces, le willLeaveApplication rappel a été supprimé au profit de applicationDidEnterBackground: et sceneDidEnterBackground: méthodes. Les API au niveau du système d'exploitation vous avertissent lorsque des utilisateurs quittent votre application, quel que soit qu'elle soit due ou non à une interaction avec une annonce.

Notez que le rappel willLeaveApplication n'a jamais été destiné à être un gestionnaire de clics sur les annonces. Avec ce rappel pour signaler les clics, pour générer une métrique précise. Par exemple, un clic sur l'onglet "Choisir sa pub" l'icône qui a lancé un navigateur externe a invoqué le rappel, mais n'a pas comptabilisé de cliquez dessus.

Modification du nom des cours

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

  • Toutes les classes associées à GADUnifiedNativeAd ont été renommées GADNativeAd
  • GADRewardBasedVideoAd, GADNativeExpressAdView et GADInstreamAd ont ont été supprimées.
  • Toutes les classes avec le préfixe DFP ont été remplacées par le préfixe GAM.
Classe v7.68.0 Classe v8.0.0
DFPBannerView GAMBannerView
DFPBannerViewOptions GAMBannerViewOptions
DFPInterstitial GAMInterstitialAd
DFPRequest GAMRequest
GADRequestError NSError
GADUnifiedNativeAdView GADNativeAdView
Annonce 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.
  • -willLeaveApplication: méthode déléguée a été supprimée pour tous les formats.
  • Le nom de 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 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 la propriété l'ancienne propriété "testDevices" a été définie à la demande.
gender (genre) Supprimée
anniversaire 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 canPresentFromRootViewController:error: à la place.
hasBeenUsed Supprimée
-init -initWithAdUnitID:
-setAdUnitID: -initWithAdUnitID:
adNetworkClassName responseInfo.adNetworkClassName
-interstitialWillLeaveApplication: Supprimée
Annonce GADUnifiedNativeAd videoController mediaContent.videoController
adNetworkClassName responseInfo.adNetworkClassName