Để thảo luận và đưa ra ý kiến phản hồi về các sản phẩm của chúng tôi, hãy tham gia kênh Discord chính thức của Ad Manager trong máy chủ Cộng đồng quảng cáo và đo lường của Google.
Quảng cáo gốc được kết xuất tuỳ chỉnh được tải thông qua các đối tượng GADAdLoader. Bạn cũng có thể định cấu hình đối tượng GADAdLoader để đưa ra các yêu cầu quảng cáo có thể dẫn đến quảng cáo biểu ngữ hoặc quảng cáo gốc. Việc thêm GADAdLoaderAdTypeGAMBanner vào tham số mảng adTypes, cùng với các loại quảng cáo gốc như GADAdLoaderAdTypeNative khi tạo đối tượng GADAdLoader sẽ chỉ định rằng quảng cáo biểu ngữ phải cạnh tranh với quảng cáo gốc để đáp ứng yêu cầu.
Khi yêu cầu quảng cáo biểu ngữ thông qua GADAdLoader, uỷ quyền trình tải quảng cáo phải tuân thủ giao thức GAMBannerAdLoaderDelegate. Giao thức này bao gồm một thông báo được gửi khi quảng cáo biểu ngữ đã tải xong:
Uỷ quyền trình tải quảng cáo cũng phải chỉ định những kích thước quảng cáo biểu ngữ cần được yêu cầu bằng cách phản hồi thông báo validBannerSizesForAdLoader như minh hoạ bên dưới.
Phương pháp tính số lượt hiển thị theo cách thủ công
Để bật tính năng đếm lượt hiển thị thủ công trên quảng cáo biểu ngữ được tải thông qua GADAdLoader, hãy đặt GAMBannerViewOptions với enableManualImpressions được đặt thành YES khi khởi tạo GADAdLoader.
Nếu quảng cáo biểu ngữ tải, bạn có thể gọi recordManualImpression khi xác định rằng một quảng cáo đã được trả về thành công và đang hiển thị trên màn hình để kích hoạt một lượt hiển thị theo cách thủ công:
[null,null,["Cập nhật lần gần đây nhất: 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```"]]