インライン アダプティブ バナー

アダプティブ バナーは次世代のレスポンシブ広告であり、デバイスごとに広告サイズを最適化してパフォーマンスを最大化します。アダプティブ バナーでは、高さが固定された固定サイズのバナーを改良しました。デベロッパーは広告の幅を指定し、それを基に最適な広告サイズを決定できます。

最適な広告サイズを選択するために、インライン アダプティブ バナーでは、固定の高さではなく最大のサイズが使用されます。これにより、パフォーマンスの向上につながります。

インライン アダプティブ バナーの用途

インライン アダプティブ バナーは、アンカー アダプティブ バナーよりも大きく縦長です。高さは可変で、デバイスの画面と同じ高さにできます。

スクロール コンテンツに配置することを意図しています。次に例を示します。

前提条件

  • Google Mobile Ads SDK 8.10.0 以降

始める前に

アプリにアダプティブ バナーを実装する際は、以下の点にご注意ください。

  • 広告が配置されるビューの幅を把握している必要があります。また、デバイスの幅と、適用されるセーフエリアについても考慮する必要があります

  • Google Mobile Ads SDK の最新バージョンを使用していることと、メディエーションを使用している場合は、メディエーション アダプタの最新バージョンを使用していることを確認してください。

  • インライン アダプティブ バナーのサイズは、利用可能な全幅を使用したときに最も効果を発揮するように設計されています。ほとんどの場合、使用するデバイスの画面の全幅になります。適切な安全領域を考慮してください。

  • アダプティブ サイズを使用するには、広告申込情報の更新または新しい作成が必要になることがあります。詳細

実装

インライン アダプティブ バナー広告を実装する手順は、アンカー アダプティブ バナー広告を実装する手順と同じです。唯一の違いは、インライン アダプティブ バナー広告は、インライン アダプティブ バナー広告のサイズを使用して読み込まれることです。インライン アダプティブ広告サイズを作成するには:

  • 使用するデバイスの幅を取得します。画面の全幅を使用しない場合は、独自の幅を設定します。
  • 広告サイズクラスの適切な静的メソッド( GADCurrentOrientationInlineBannerAdSizeWithWidth(CGFloat width) など)を使用して、選択した向きのインライン アダプティブ広告サイズ オブジェクトを取得します。
  • バナーの高さを制限する場合は、静的メソッド GADInlineAdaptiveBannerAdSizeWithWidthAndMaxHeight(CGFloat width, CGFloat maxHeight) を使用します。

以下のサンプルコードは、この手順を示しています。

Swift

// Step 1: Create an inline adaptive banner ad size. This size is used to
// request your adaptive banner. You can pass in the width of the device, or set
// your own width. This example sets a static width.
let adSize = GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(320)
// Step 2: Create banner with the inline size and set ad unit ID.
let bannerView = GAMBannerView(adSize: adSize)
bannerView.adUnitID = "ad unit ID"
bannerView.rootViewController = self

// For Ad Manager, the `adSize` property is used for the adaptive banner ad
// size. The `validAdSizes` property is used as normal for the supported
// reservation sizes for the ad placement.
bannerView.validAdSizes = [NSValueFromGADAdSize(GADAdSizeBanner)]

// Step 3: Load an ad.
let request = GAMRequest()
bannerView.load(request)
// TODO: Insert banner view in table view or scroll view, etc.

Objective-C

// Step 1: Create an inline adaptive banner ad size. This size is used to
// request your adaptive banner. You can pass in the width of the device, or set
// your own width. This example sets a static width.
GADAdSize *adSize = GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(320);
// Step 2: Create banner with the inline size and set ad unit ID.
GAMBannerView bannerView = [[GAMBannerView alloc] initWithAdSize:adSize];
bannerView.adUnitID = @"ad unit ID";
bannerView.rootViewController = self;

// For Ad Manager, the adSize property is used for the adaptive banner ad size.
// The validAdSizes property is used as normal for the supported reservation
// sizes for the ad placement. This is optional and only needed if you wish to
// support reservation ad sizes.
bannerView.validAdSizes = @[ NSValueFromGADAdSize(GADAdSizeBanner) ];

// Step 3: Load an ad.
GAMRequest *request = [GAMRequest request];
[bannerView loadRequest:request];
// TODO: Insert banner view in table view or scroll view, etc.

補足資料

GitHub の例

サンプル アプリケーションをダウンロードして、インライン アダプティブ バナーの動作をご確認ください。

Swift Objective-C