可收合橫幅廣告

選取平台: Android iOS Unity Flutter

可收合橫幅廣告一開始會以較大的重疊廣告顯示,並提供按鈕,可將廣告收合為原始要求的橫幅廣告大小。可收合橫幅廣告的目的是提升錨定廣告的成效,否則錨定廣告的尺寸會較小。本指南說明如何為現有橫幅刊登位置啟用可收合式橫幅廣告。

必要條件

導入作業

請確認橫幅檢視畫面已定義使用者在一般 (收合) 橫幅狀態中看到的尺寸。在廣告請求中加入 extras 參數,並將 collapsible 設為鍵,廣告刊登位置設為值。

可收合刊登位置會定義展開區域如何錨定至橫幅廣告。

Placement 行為 預定用途
top 展開廣告的頂端會與收合廣告的頂端對齊。 廣告位於畫面頂端。
bottom 展開廣告的底部會對齊收合廣告的底部。 廣告會顯示在畫面底部。

如果載入的廣告是可收合式橫幅,橫幅就會在置於檢視區塊階層後,立即顯示可收合的疊加層。

void _loadAd() async {
  // Replace these test ad units with your own ad units.
  final String adUnitId = Platform.isAndroid
    ? 'ca-app-pub-3940256099942544/2014213617'
    : 'ca-app-pub-3940256099942544/8388050270';

  // Get the size before loading the ad.
  final size = await AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(
      MediaQuery.sizeOf(context).width.truncate());

  if (size == null) {
    // Unable to get the size.
    return;
  }

  // Create an extra parameter that aligns the bottom of the expanded ad to the
  // bottom of the banner ad.
  const adRequest = AdRequest(extras: {
    "collapsible": "bottom",
  });

  BannerAd(
      adUnitId: adUnitId,
      request: adRequest,
      size: size,
      listener: const BannerAdListener()
  ).load();
}

廣告重新整理行為

如果應用程式在 AdMob 網路介面中設定橫幅廣告自動重新整理,當橫幅廣告版位請求可收合橫幅廣告時,後續重新整理廣告時不會再請求這類廣告。這是因為在每次重新整理時顯示可收合橫幅廣告,可能會對使用者體驗造成負面影響。

如要在工作階段中的一段時間後,再載入其他可收合橫幅廣告,請在請求中包含可收合橫幅廣告參數,並手動載入廣告。

中介服務

可收合橫幅廣告僅適用於 Google 需求。透過中介服務放送的廣告會正常顯示,不會是可收合的橫幅廣告。