Skip to content

Consent

Google's User Messaging Platform (UMP) SDK is the privacy and messaging tool for gathering consent before you request ads. Google's UMP guides for Android and iOS explain the flow.

This plugin exposes UMP and iOS App Tracking Transparency through one API. Before using UMP, create your GDPR (General Data Protection Regulation) messages in AdMob. You may also set up Identifier for Advertisers (IDFA) messages. When IDFA messages are published, UMP presents them and the App Tracking Transparency prompt; do not also call requestTrackingAuthorization().

  1. Call AdMob.initialize(). See Configuration.
  2. Call AdMob.requestConsentInfo().
  3. If required, call AdMob.showConsentForm().
  4. Load ads only when consentInfo.canRequestAds is true.
import { AdMob, AdmobConsentStatus } from '@capacitor-community/admob';

await AdMob.initialize();

let consentInfo = await AdMob.requestConsentInfo();
if (consentInfo.isConsentFormAvailable && consentInfo.status === AdmobConsentStatus.REQUIRED) {
  consentInfo = await AdMob.showConsentForm();
}

if (consentInfo.canRequestAds) {
  // Ads may now be requested.
}

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

interface AdmobConsentInfo

Prop Type Description Since
status AdmobConsentStatus The consent status of the user. 5.0.0
isConsentFormAvailable boolean If true a consent form is available and vice versa. 5.0.0
canRequestAds boolean If true an ad can be shown. 7.0.3
privacyOptionsRequirementStatus PrivacyOptionsRequirementStatus Privacy options requirement status of the user. 7.0.3

enum AdmobConsentStatus

Member Value Description
NOT_REQUIRED 'NOT_REQUIRED' User consent not required.
OBTAINED 'OBTAINED' User consent already obtained.
REQUIRED 'REQUIRED' User consent required but not yet obtained.
UNKNOWN 'UNKNOWN' Unknown consent status, AdsConsent.requestInfoUpdate needs to be called to update it.

method showConsentForm()

Shows a google user consent form (rendered from your GDPR message config).

showConsentForm() => Promise<AdmobConsentInfo>

Use canRequestAds as the decision point. A consent form may be unavailable or unnecessary depending on the user and the messages you configured.

iOS tracking authorization

If you are not using UMP IDFA messages, request App Tracking Transparency yourself when the status is notDetermined. Skip this section when Identifier for Advertisers messages are configured in AdMob; UMP shows that prompt.

const tracking = await AdMob.trackingAuthorizationStatus();
if (tracking.status === 'notDetermined') {
  /**
   * If you want to explain tracking before the iOS dialog,
   * present your own UI here, then continue.
   */
  await AdMob.requestTrackingAuthorization();
}

requestTrackingAuthorization() does nothing on Android, web, and iOS versions before 14.

method trackingAuthorizationStatus()

Returns the current App Tracking Transparency authorization status on iOS 14 and later.
Returns authorized on earlier iOS versions, Android, and web.

trackingAuthorizationStatus() => Promise<TrackingAuthorizationStatusInterface>

interface TrackingAuthorizationStatusInterface

The current iOS App Tracking Transparency authorization status.

Prop Type Description
status 'authorized' | 'denied' | 'notDetermined' | 'restricted' The authorization status reported by App Tracking Transparency.

method requestTrackingAuthorization()

Requests App Tracking Transparency authorization on iOS 14 and later.
Resolves without taking action on earlier iOS versions, Android, and web.

requestTrackingAuthorization() => Promise<void>

Privacy options

If your privacy message requires an in-app entry point, expose a settings action that calls:

await AdMob.showPrivacyOptionsForm();

method showPrivacyOptionsForm()

Shows a google privacy options form (rendered from your GDPR message config).

showPrivacyOptionsForm() => Promise<void>

resetConsentInfo() is intended for testing. Do not use it to clear a production user's consent choice.

method resetConsentInfo()

Resets the UMP SDK state. Call requestConsentInfo function again to allow user modify their consent

resetConsentInfo() => Promise<void>

For debug geography and test device IDs, see Testing.