Pour discuter de nos produits et nous faire part de vos commentaires, rejoignez le canal Discord officiel Ad Manager sur le serveur de la communauté Google Advertising and Measurement.
Les annonces natives affichées de manière personnalisée sont chargées via des objets GADAdLoader. L'objet GADAdLoader peut également être configuré pour effectuer des demandes d'annonces pouvant générer une bannière ou une annonce native. L'ajout de GADAdLoaderAdTypeGAMBanner au paramètre de tableau adTypes, ainsi que les types d'annonces natives tels que GADAdLoaderAdTypeNative lors de la création de l'objet GADAdLoader, indique que les bannières publicitaires doivent être en concurrence avec les annonces natives pour répondre à la demande.
Lorsque vous demandez des bannières via GADAdLoader, le délégué du chargeur d'annonces doit respecter le protocole GAMBannerAdLoaderDelegate. Ce protocole inclut un message envoyé lorsqu'une bannière publicitaire a été chargée :
Le délégué du chargeur d'annonces doit également spécifier les tailles de bannières à demander en répondant au message validBannerSizesForAdLoader, comme indiqué ci-dessous.
Pour activer le comptage manuel des impressions sur les bannières chargées via GADAdLoader, définissez un GAMBannerViewOptions avec enableManualImpressions défini sur YES lors de l'initialisation de GADAdLoader.
Si une bannière publicitaire se charge, vous pouvez appeler recordManualImpression lorsque vous déterminez qu'une annonce a été renvoyée avec succès et qu'elle est à l'écran pour déclencher manuellement une impression :
Swift
bannerView.recordImpression()
Objective-C
[self.bannerViewrecordImpression];
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/08/27 (UTC).
[null,null,["Dernière mise à jour le 2025/08/27 (UTC)."],[[["\u003cp\u003eYou can combine native and banner ads in your ad requests by including both \u003ccode\u003eGADAdLoaderAdTypeNative\u003c/code\u003e and \u003ccode\u003eGADAdLoaderAdTypeGAMBanner\u003c/code\u003e when creating a \u003ccode\u003eGADAdLoader\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003eTo receive banner ads through a \u003ccode\u003eGADAdLoader\u003c/code\u003e, your ad loader delegate must conform to the \u003ccode\u003eGAMBannerAdLoaderDelegate\u003c/code\u003e protocol and specify the desired banner ad sizes.\u003c/p\u003e\n"],["\u003cp\u003eWhen loading banner ads via \u003ccode\u003eGADAdLoader\u003c/code\u003e, manual impression counting can be enabled using \u003ccode\u003eGAMBannerViewOptions\u003c/code\u003e and calling \u003ccode\u003erecordManualImpression\u003c/code\u003e when the ad is displayed.\u003c/p\u003e\n"],["\u003cp\u003eRemember that banner ads loaded through \u003ccode\u003eGADAdLoader\u003c/code\u003e will not refresh and that requesting banners alone requires following the separate banner guide.\u003c/p\u003e\n"]]],[],null,["With a few changes to your code, you can combine native and banner ads in your\nad requests.\n\nPrerequisites\n\n- Version 7.20.0 or higher of the Google Mobile Ads SDK\n- Complete the [Get Started](/ad-manager/mobile-ads-sdk/ios/quick-start) guide\n\nLoading an ad\n\nCustom-rendered native ads are loaded via\n[`GADAdLoader`](/ad-manager/mobile-ads-sdk/ios/api/reference/Classes/GADAdLoader)\nobjects. The `GADAdLoader` object can also be configured to make ad requests\nthat can result in either a banner or native ad. Adding\n`GADAdLoaderAdTypeGAMBanner` to the `adTypes` array parameter, along with\nnative ad types such as `GADAdLoaderAdTypeNative` when creating the\n`GADAdLoader` object specifies that banner ads should compete with native ads\nto fill the request. \n\nSwift \n\n```swift\nadLoader = GADAdLoader(adUnitID: \"/21775744923/example/native-and-banner\",\n rootViewController: self,\n adTypes: [.native, .gamBanner],\n options: [... ad loader options objects ...])\nadLoader.delegate = self\n```\n\nObjective-C \n\n```objective-c\nself.adLoader = [[GADAdLoader alloc]\n initWithAdUnitID:@\"/21775744923/example/native-and-banner\"\n rootViewController:rootViewController\n adTypes:@[ GADAdLoaderAdTypeNative, GADAdLoaderAdTypeGAMBanner ]\n options:@[ ... ad loader options objects ... ]];\nself.adLoader.delegate = self;\n```\n| **Note:** Banner ads can only be loaded via `GADAdLoader` objects when requested alongside native ads. To make an ad request for banners alone, follow the steps outlined in the in the [banner guide](/ad-manager/mobile-ads-sdk/ios/banner). In addition, banners loaded via `GADAdLoader` objects will not refresh.\n\nGAMBannerAdLoaderDelegate\n\nWhen requesting banner ads via the `GADAdLoader`, the ad loader delegate must\nconform to the `GAMBannerAdLoaderDelegate` protocol. This protocol includes a\nmessage that's sent when a banner ad has loaded: \n\nSwift \n\n```swift\npublic func adLoader(_ adLoader: GADAdLoader,\n didReceive GAMBannerView: GAMBannerView)\n```\n\nObjective-C \n\n```objective-c\n- (void)adLoader:(GADAdLoader *)adLoader didReceiveGAMBannerView:(GAMBannerView *)bannerView;\n```\n\nThe ad loader delegate must also specify which banner ad sizes should be\nrequested by responding to the `validBannerSizesForAdLoader` message as shown\nbelow. \n\nSwift \n\n```swift\npublic func validBannerSizes(for adLoader: GADAdLoader) -\u003e [NSValue] {\n return [NSValueFromGADAdSize(GADAdSizeBanner),\n NSValueFromGADAdSize(GADAdSizeMediumRectangle),\n NSValueFromGADAdSize(GADAdSizeFromCGSize(CGSize(width: 120, height: 20)))]\n}\n```\n\nObjective-C \n\n```objective-c\n- (NSArray *)validBannerSizesForAdLoader:(GADAdLoader *)adLoader {\n return @[\n @(GADAdSizeBanner),\n @(GADAdSizeMediumRectangle),\n @(GADAdSizeFromCGSize(CGSizeMake(120, 20)))\n ];\n}\n```\n| **Note:** Don't create your own `GADAdSize` directly. Use one of the predefined ad sizes (such as `GADAdSizeBanner`), or create one using the `GADAdSizeFromCGSize` method, as shown above.\n\nManual impression counting\n\nTo enable [manual impression\ncounting](/ad-manager/mobile-ads-sdk/ios/banner#manual_impression_counting)\non banner ads loaded through `GADAdLoader`, set a\n[`GAMBannerViewOptions`](/ad-manager/mobile-ads-sdk/ios/api/reference/Classes/GAMBannerViewOptions)\nwith `enableManualImpressions` set to `YES` when initializing `GADAdLoader`. \n\nSwift \n\n```swift\nlet bannerViewOptions = GAMBannerViewOptions()\nbannerViewOptions.enableManualImpressions = true\nadLoader = GADAdLoader(\n adUnitID: \"/21775744923/example/native-and-banner\", rootViewController: self,\n adTypes: [.native, .gamBanner], options: [bannerViewOptions])\n```\n\nObjective-C \n\n```objective-c\nGAMBannerViewOptions *bannerViewOptions = [[GAMBannerViewOptions alloc] init];\nbannerViewOptions.enableManualImpressions = YES;\nself.adLoader = [[GADAdLoader alloc]\n initWithAdUnitID:@\"/21775744923/example/native-and-banner\"\n rootViewController:self\n adTypes:@[ GADAdLoaderAdTypeNative, GADAdLoaderAdTypeGAMBanner ]\n options:@[ bannerViewOptions ]];\n```\n\nIf a banner ad loads, you can call `recordManualImpression` when you\ndetermine that an ad has been successfully returned and is on-screen to\nmanually fire an impression: \n\nSwift \n\n```swift\nbannerView.recordImpression()\n```\n\nObjective-C \n\n```objective-c\n[self.bannerView recordImpression];\n```"]]