本文へ移動

初期化

広告をリクエストする前に、プラグインの initialize を一度呼び出します。ネイティブ SDK を自分で起動する必要はありません。

ネイティブのアプリ ID は AndroidManifest / Info.plist に置きます。インストール を見てください。

import { AdMob } from '@capacitor-community/admob';

await AdMob.initialize();

method initialize(...)

Initializes the Google Mobile Ads SDK.

initialize(options?: AdMobInitializationOptions | undefined) => Promise<void>

interface AdMobInitializationOptions

Prop Type Description Default Since
testingDevices string[] Device IDs to register as test devices when {@link AdMobInitializationOptions.initializeForTesting} is true. Requests from registered devices receive test ads and do not generate invalid traffic. 1.2.0
initializeForTesting boolean Whether to register {@link AdMobInitializationOptions.testingDevices} as test devices. false 1.2.0
tagForChildDirectedTreatment boolean For purposes of the Children's Online Privacy Protection Act (COPPA), there is a setting called tagForChildDirectedTreatment. 3.1.0
tagForUnderAgeOfConsent boolean When using this feature, a Tag For Users under the Age of Consent in Europe (TFUA) parameter will be included in all future ad requests. 3.1.0
maxAdContentRating MaxAdContentRating The maximum ad content rating applied to all ad requests. Ads with a higher rating are excluded. 3.1.0

開発中は Google の デモ広告ユニット を優先してください。実機で本番に近い広告を試す場合は、テスト の手順でデバイスを登録します。本番に initializeForTesting: true を入れないでください。

isTestingnpa(非パーソナライズ広告)、immersiveMode(フルスクリーン広告中に Android のシステムバーを隠す)などの広告単位のオプションは initialize ではなく各リクエストに付けます。各形式のガイドを見てください。

初期化のあと、広告をロードする前にプライバシー同意を取ります。同意管理 を見てください。