Stay organized with collections Save and categorize content based on your preferences.
The Google User Messaging Platform (UMP) SDK is a privacy and messaging tool to help you manage privacy choices. For more information, see About Privacy & messaging.
PrerequisitesCreate user messages with one of the Available user message types under the Privacy & messaging tab of your AdMob account. The UMP SDK attempts to display a privacy message created from the AdMob Application ID set in your project.
For more details, see About privacy and messaging.
Install with GradleAdd the dependency for the Google User Messaging Platform SDK to your module's app-level Gradle file, normally app/build.gradle
:
dependencies {
implementation("com.google.android.ump:user-messaging-platform:3.1.0")
}
After making the changes to your app's build.gradle
, be sure to sync your project with Gradle files.
You can find your application ID in the AdMob UI. Add the ID to your AndroidManifest.xml
with the following code snippet:
<manifest>
<application>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
</application>
</manifest>
Get the user's consent information
To get the user's consent information, do the following:
Declare an instance of ConsentInformation
:
private final ConsentInformation consentInformation;
Kotlin
private lateinit val consentInformation: ConsentInformation
Initialize the ConsentInformation
instance:
consentInformation = UserMessagingPlatform.getConsentInformation(context);
Kotlin
consentInformation = UserMessagingPlatform.getConsentInformation(context)
You should request an update of the user's consent information at every app launch, using requestConsentInfoUpdate()
. This request checks the following:
// Requesting an update to consent information should be called on every app launch.
consentInformation.requestConsentInfoUpdate(
activity,
params,
() -> // Called when consent information is successfully updated.
requestConsentError -> // Called when there's an error updating consent information.
Kotlin
// Requesting an update to consent information should be called on every app launch.
consentInformation.requestConsentInfoUpdate(
activity,
params,
{
// Called when consent information is successfully updated.
},
{ requestConsentError ->
// Called when there's an error updating consent information.
},
)
Warning: Using other ways of checking consent status, such as the cache on your app or a previously saved consent string, can lead to a TCF 3.3 error if consent is expired. Load and present the privacy message form
After you have received the most up-to-date consent status, call loadAndShowConsentFormIfRequired()
to load any forms required to collect user consent. After loading, the forms present immediately.
UserMessagingPlatform.loadAndShowConsentFormIfRequired(
activity,
formError -> {
// Consent gathering process is complete.
});
Kotlin
UserMessagingPlatform.loadAndShowConsentFormIfRequired(activity) { formError ->
// Consent gathering process is complete.
}
Privacy options
Some privacy message forms are presented from a publisher-rendered privacy options entry point, letting users manage their privacy options at any time. To learn more about which message your users see at the privacy options entry point, see Available user message types.
Check if a privacy options entry point is requiredAfter you have called requestConsentInfoUpdate()
, check getPrivacyOptionsRequirementStatus()
to determine if a privacy options entry point is required for your app. If an entry point is required, add a visible and interactable UI element to your app that presents the privacy options form. If a privacy entry point is not required, configure your UI element to be not visible and interactable.
/** Helper variable to determine if the privacy options form is required. */
public boolean isPrivacyOptionsRequired() {
return consentInformation.getPrivacyOptionsRequirementStatus()
== PrivacyOptionsRequirementStatus.REQUIRED;
}
Kotlin
/** Helper variable to determine if the privacy options form is required. */
val isPrivacyOptionsRequired: Boolean
get() =
consentInformation.privacyOptionsRequirementStatus ==
ConsentInformation.PrivacyOptionsRequirementStatus.REQUIRED
For the full list of privacy options requirement statuses, see ConsentInformation.PrivacyOptionsRequirementStatus
.
When the user interacts with your element, present the privacy options form:
Java
UserMessagingPlatform.showPrivacyOptionsForm(activity, onConsentFormDismissedListener);
Kotlin
UserMessagingPlatform.showPrivacyOptionsForm(activity, onConsentFormDismissedListener)
Request ads with user consent
Before requesting ads, use canRequestAds()
to check if you've obtained consent from the user:
consentInformation.canRequestAds();
Kotlin
consentInformation.canRequestAds()
Listed are the following places to check if you can request ads while gathering consent:
requestConsentInfoUpdate()
. The UMP SDK might have obtained consent in the previous app session. canRequestAds()
always returns false
until you have called requestConsentInfoUpdate()
If an error occurs during the consent gathering process, check if you can request ads. The UMP SDK uses the consent status from the previous app session.
Prevent redundant ad request workAs you check canRequestAds()
after gathering consent and after calling requestConsentInfoUpdate()
, ensure your logic prevents redundant ad requests that might result in both checks returning true
. For example, with a boolean variable.
If you want to test the integration in your app as you're developing, follow these steps to programmatically register your test device. Be sure to remove the code that sets these test device IDs before you release your app.
Note: As of version 2.2.0, emulators don't need to be added to your device ID list as they are test devices by default. requestConsentInfoUpdate()
.Check the log output for a message similar to the following example, which shows your device ID and how to add it as a test device:
Use new ConsentDebugSettings.Builder().addTestDeviceHashedId("33BE2250B43518CCDA7DE426D04EE231") to set this as a debug device.
Copy your test device ID to your clipboard.
Modify your code to call ConsentDebugSettings.Builder().TestDeviceHashedIds
and pass in a list of your test device IDs.
ConsentDebugSettings debugSettings = new ConsentDebugSettings.Builder(this)
.addTestDeviceHashedId("TEST-DEVICE-HASHED-ID")
.build();
ConsentRequestParameters params = new ConsentRequestParameters
.Builder()
.setConsentDebugSettings(debugSettings)
.build();
consentInformation = UserMessagingPlatform.getConsentInformation(this);
// Include the ConsentRequestParameters in your consent request.
consentInformation.requestConsentInfoUpdate(
this,
params,
// ...
);
Kotlin
val debugSettings = ConsentDebugSettings.Builder(this)
.addTestDeviceHashedId("TEST-DEVICE-HASHED-ID")
.build()
val params = ConsentRequestParameters
.Builder()
.setConsentDebugSettings(debugSettings)
.build()
consentInformation = UserMessagingPlatform.getConsentInformation(this)
// Include the ConsentRequestParameters in your consent request.
consentInformation.requestConsentInfoUpdate(
this,
params,
// ...
)
The UMP SDK provides a way to test your app's behavior as though the device were located in various regions, such as the EEA or UK, using setDebugGeography()
. Note that debug settings only work on test devices.
ConsentDebugSettings debugSettings = new ConsentDebugSettings.Builder(this)
.setDebugGeography(ConsentDebugSettings.DebugGeography.DEBUG_GEOGRAPHY_EEA)
.addTestDeviceHashedId("TEST-DEVICE-HASHED-ID")
.build();
ConsentRequestParameters params = new ConsentRequestParameters
.Builder()
.setConsentDebugSettings(debugSettings)
.build();
consentInformation = UserMessagingPlatform.getConsentInformation(this);
// Include the ConsentRequestParameters in your consent request.
consentInformation.requestConsentInfoUpdate(
this,
params,
...
);
Kotlin
val debugSettings = ConsentDebugSettings.Builder(this)
.setDebugGeography(ConsentDebugSettings.DebugGeography.DEBUG_GEOGRAPHY_EEA)
.addTestDeviceHashedId("TEST-DEVICE-HASHED-ID")
.build()
val params = ConsentRequestParameters
.Builder()
.setConsentDebugSettings(debugSettings)
.build()
consentInformation = UserMessagingPlatform.getConsentInformation(this)
// Include the ConsentRequestParameters in your consent request.
consentInformation.requestConsentInfoUpdate(
this,
params,
...
)
Reset consent state
When testing your app with the UMP SDK, you might find it helpful to reset the state of the SDK so that you can simulate a user's first install experience. The SDK provides the reset()
method to do this.
consentInformation.reset();
Kotlin
consentInformation.reset()
Caution: This method is intended to be used for testing purposes only. You shouldn't call reset()
in production code. Examples on GitHub
See a full example of the UMP SDK integration covered in this page in Java BannerExample and Kotlin BannerExample.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-10 UTC."],[[["The Google User Messaging Platform (UMP) SDK helps you manage user privacy choices and display relevant privacy messages within your Android app."],["You need to integrate the UMP SDK into your app, add your AdMob Application ID, and request consent information from users at each app launch."],["If required, the SDK will display a privacy message form to collect user consent before you can request ads."],["You can implement a privacy options entry point to allow users to manage their privacy choices at any time."],["Before requesting ads, ensure you've obtained consent using `canRequestAds()` and handle potential errors during consent gathering."]]],["The Google UMP SDK manages user privacy choices. Key actions include: installing the SDK via Gradle, adding the AdMob application ID to `AndroidManifest.xml`, and initializing `ConsentInformation`. At each app launch, update user consent via `requestConsentInfoUpdate()`. Load and show consent forms using `loadAndShowConsentFormIfRequired()`, or present privacy options via `showPrivacyOptionsForm()` if needed. Check `canRequestAds()` before ad requests. For testing, add device IDs and set debug geography; `reset()` the consent state when testing.\n"]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3