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

アダプティブ バナーは次世代のレスポンシブ広告であり、 デバイスごとに広告サイズを最適化することでパフォーマンスが向上します。固定サイズの改善 固定された高さしかサポートされなかった アダプティブバナーを使うと 広告の幅を指定し、それに基づいて最適な広告サイズを判断します。

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

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

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

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

前提条件

  • 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 = GADBannerView(adSize: adSize)
bannerView.adUnitID = "<var>ad unit ID</var>"
bannerView.rootViewController = self

// Step 3: Load an ad.
let request = GADRequest()
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.
GADBannerView bannerView = [[GADBannerView alloc] initWithAdSize:adSize];
bannerView.adUnitID = @"<var>ad unit ID</var>";
bannerView.rootViewController = self;

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

参考情報

GitHub の例

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

Swift Objective-C