折叠式横幅广告

折叠式横幅广告是一种横幅广告,初始展示时采用较大的 重叠式广告,且带有一个按钮可将其折叠为最初请求的横幅广告尺寸。 折叠式横幅广告旨在提升 否则会比较小本指南介绍了如何启用折叠式横幅广告 现有横幅广告展示位置的广告。

前提条件

实现

请确保使用您希望用户看到的尺寸来定义横幅广告视图 处于常规(已收起)横幅广告状态。在广告中添加 extras 参数 以 collapsible 为键,以广告的展示位置作为值。

可折叠的展示位置定义展开区域如何锚定到横幅广告 。

Placement 行为 预期用例
top 展开的广告的顶部与折叠广告的顶部对齐。 广告位于屏幕的顶部。
bottom 展开后广告的底部与展开前广告的底部对齐 。 广告位于屏幕底部。

如果加载的广告是折叠式横幅广告,横幅广告会显示 立即叠加。

Swift

func loadBannerAd() {
   bannerView.adUnitID = "ca-app-pub-3940256099942544/8388050270"
   bannerView.rootViewController = self
   let viewWidth = FRAME_WIDTH
   bannerView.adSize = GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(viewWidth)

   let request = GADRequest()

   // Create an extra parameter that aligns the bottom of the expanded ad to
   // the bottom of the bannerView.
   let extras = GADExtras()
   extras.additionalParameters = ["collapsible" : "bottom"]
   request.register(extras)

   bannerView.load(request)
 }

Objective-C

- (void)loadBannerAd {
  self.bannerView.adUnitID = @"ca-app-pub-3940256099942544/8388050270";
  CGFloat viewWidth = FRAME_WIDTH;
  self.bannerView.adSize = GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(viewWidth);

  GADRequest *request = [GADRequest request];

  // Create an extra parameter that aligns the bottom of the expanded ad to the
  // bottom of the bannerView.
  GADExtras *extras = [[GADExtras alloc] init];
  extras.additionalParameters = @{@"collapsible" : @"bottom"};
  [request registerAdNetworkExtras:extras];

  [self.bannerView loadRequest:request];
}

广告刷新行为

对于在 显示折叠式横幅广告时,AdMob 网页界面中的 横幅广告位请求后,后续的广告刷新就不会再请求 折叠式横幅广告这是因为 可能会对用户体验产生负面影响。

如果希望稍后在此会话中加载另一个折叠式横幅广告,您可以 通过包含可折叠参数的请求手动加载广告。

检查已加载的广告是否可折叠

调用 isCollapsible 以检查加载的最后一个横幅广告是否可折叠。 如果请求无法加载,且之前的横幅广告可折叠,则 API 返回 true。

Swift

func bannerViewDidReceiveAd(_ bannerView: GADBannerView) {
  print("The last loaded banner is \(bannerView.isCollapsible ? "" : "not") collapsible.")
}

Objective-C

- (void)bannerViewDidReceiveAd:(GADBannerView *)bannerView {
  NSLog(@"The last loaded banner is %@collapsible.", (bannerView.isCollapsible ? @"" : @"not "));
}

中介

折叠式横幅广告在 Beta 版阶段仅适用于 Google 需求来源 。通过中介投放的广告将显示为常规的不可折叠横幅广告。

广告投放行为

为使横幅广告的效果达到最佳,不支持尺寸更大的广告 折叠式重叠式广告可能会返回一些折叠式横幅广告请求, 立即采用常规横幅广告尺寸