Skip to content

Testing

Use test ads during development so you can click ads without charging advertisers or flagging the account for invalid traffic. Google's test ads guides for Android and iOS explain demo ad units and test devices.

This plugin can request those demo units or register a device through initialize.

Demo ad units

Google provides demo ad units that always return test ads. Prefer these during development. This plugin supports native iOS and Android only—use the matching platform ID.

Banner demo units used by this plugin and its demo:

Platform Banner adId
Android ca-app-pub-3940256099942544/6300978111
iOS ca-app-pub-3940256099942544/2934735716

Other format demo IDs are listed in Google's test-ads guides linked above. You can also set isTesting: true on banner, interstitial, rewarded, and rewarded interstitial requests. App Open ads have no isTesting option; pass a demo ad unit as adId.

Test devices

To request production-like ads on a physical device without generating invalid traffic, register the device with AdMob.initialize():

await AdMob.initialize({
  testingDevices: ['YOUR_TEST_DEVICE_ID'],
  initializeForTesting: true,
});

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

Find the device ID in the native logs after the first ad request:

  • Android: Logcat, typically on the Ads tag (Use RequestConfiguration.Builder.setTestDeviceIds(...)).
  • iOS: Xcode console (To get test ads on this device, set:).

See Google's enable test devices guide.

On a real device, set debugGeography and include the device ID in testDeviceIdentifiers. EEA makes the form behave as if the device were in the European Economic Area, so you can test GDPR messaging. Use this only on registered test devices.

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

const consentInfo = await AdMob.requestConsentInfo({
  debugGeography: AdmobConsentDebugGeography.EEA,
  testDeviceIdentifiers: ['YOUR_TEST_DEVICE_ID'],
});

method requestConsentInfo(...)

Request user consent information

requestConsentInfo(options?: AdmobConsentRequestOptions | undefined) => Promise<AdmobConsentInfo>

interface AdmobConsentRequestOptions

Prop Type Description Default Since
debugGeography AdmobConsentDebugGeography Sets the debug geography to test the consent locally. 5.0.0
testDeviceIdentifiers string[] An array of test device IDs to allow. Note: On iOS, the ID may renew if you uninstall and reinstall the app. 5.0.0
tagForUnderAgeOfConsent boolean Set to true to provide the option for the user to accept being shown personalized ads. false 5.0.0

enum AdmobConsentDebugGeography

Member Value Description
DISABLED 0 Debug geography disabled.
EEA 1 Geography appears as in EEA for debug devices.
NOT_EEA 2 Geography appears as not in EEA for debug devices.
US 3 Geography appears as in regulated US state for debug devices.
OTHER 4 Geography appears as OTHER state for debug devices.

If you decline consent in the test form (Manage → Confirm Choices), ads may not load. That is expected in a test environment and does not predict production behavior after a user consents.

resetConsentInfo() is for tests only. See Consent.

Server-side verification

Server-side verification (SSV) callbacks fire only for production ads. Test ads will not hit your SSV endpoint. For a mock request example, see Rewarded Ads.