Skip to content

Initialize

Call the plugin's initialize once before requesting ads. You do not start the native SDK yourself.

Native application IDs belong in AndroidManifest / Info.plist; see Installation.

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

During development, prefer Google demo ad units. To test production-like ads on a physical device, register that device as described in Testing. Do not ship initializeForTesting: true in production.

Per-ad options such as isTesting, npa (non-personalized ads), and immersiveMode (hide Android system bars on a full-screen ad) are set on each ad request, not on initialize. See the per-format guides.

After initialization, request privacy consent before loading ads. See Consent.