Get started

  • The Google User Messaging Platform (UMP) SDK helps manage user privacy choices by displaying privacy messages created in your AdMob account.

  • You should request an update of the user's consent information using Update() at every app launch to check if consent is required or if a privacy options entry point is needed.

  • After updating consent status, call LoadAndShowConsentFormIfRequired() to display any necessary consent forms.

  • Implement a privacy options entry point in your app if required by checking PrivacyOptionsRequirementStatus and using ShowPrivacyOptionsForm().

  • Use CanRequestAds() after gathering consent to determine if ads can be requested.

Select platform: Android iOS Unity Flutter

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.

Create a message type

Create 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.

You should request an update of the user's consent information at every app launch, using Update(). This request checks the following:

  • Whether consent is required. For example, consent is required for the first time, or the previous consent decision expired.
  • Whether a privacy options entry point is required. Some privacy messages require apps to allow users to modify their privacy options at any time.
void Start()
{
    // Create a ConsentRequestParameters object.
    ConsentRequestParameters requestParameters = new ConsentRequestParameters();

    // Request an update of the user's consent information.
    ConsentInformation.Update(requestParameters, OnConsentInfoUpdated);
}

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.

ConsentForm.LoadAndShowConsentFormIfRequired((FormError formError) =>
{
    if (formError != null)
    {
        // Consent gathering failed.
        Debug.LogError("Error loading/showing consent form: " + formError.Message);
    }

    // ...
});

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 required

After you have called Update(), check PrivacyOptionsRequirementStatus 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.

void UpdatePrivacyButton()
{
    if (_privacyButton != null)
    {
        // Enable the button only if a privacy options entry point is required.
        _privacyButton.interactable =
            ConsentInformation.PrivacyOptionsRequirementStatus == PrivacyOptionsRequirementStatus.Required;
    }
}

For the full list of privacy options requirement statuses, see ConsentInformation.PrivacyOptionsRequirementStatus.

Present the privacy options form

When the user interacts with your element, present the privacy options form:

public void ShowPrivacyOptionsForm()
{
    ConsentForm.ShowPrivacyOptionsForm((FormError showError) =>
    {
        if (showError != null)
        {
            Debug.LogError("Error showing privacy options form: " + showError.Message);
        }
    });
}

Request ads with user consent

Before requesting ads, use CanRequestAds() to check if you've obtained consent from the user:

ConsentInformation.CanRequestAds()

Listed are the following places to check if you can request ads while gathering consent:

  • After the UMP SDK gathers consent in the current session.
  • Immediately after you have called Update(). The UMP SDK might have obtained consent in the previous app session.

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 work

As you check CanRequestAds() after gathering consent and after calling Update(), ensure your logic prevents redundant ad requests that might result in both checks returning true. For example, with a boolean variable.

Testing

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.

  1. Call Update().
  2. 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:

    Android

    Use new ConsentDebugSettings.Builder().addTestDeviceHashedId("33BE2250B43518CCDA7DE426D04EE231")
    to set this as a debug device.
    

    iOS

    <UMP SDK>To enable debug mode for this device,
    set: UMPDebugSettings.testDeviceIdentifiers = @[2077ef9a63d2b398840261c8221a0c9b]
    
  3. Copy your test device ID to your clipboard.

  4. Modify your code to call DebugGeography.TestDeviceHashedIds and pass in a list of your test device IDs.

    void Start()
    {
        var debugSettings = new ConsentDebugSettings
        {
            TestDeviceHashedIds =
            new List<string>
            {
                "TEST-DEVICE-HASHED-ID"
            }
        };
    
        // Create a ConsentRequestParameters object.
        ConsentRequestParameters request = new ConsentRequestParameters
        {
            ConsentDebugSettings = debugSettings,
        };
    
        // Check the current consent information status.
        ConsentInformation.Update(request, OnConsentInfoUpdated);
    }
    

Force a geography

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 DebugGeography. Note that debug settings only work on test devices.

void Start()
{
    var debugSettings = new ConsentDebugSettings
    {
        // Geography appears as in EEA for debug devices.
        DebugGeography = DebugGeography.EEA,
        TestDeviceHashedIds = new List<string>
        {
            "TEST-DEVICE-HASHED-ID"
        }
    };

    // Create a ConsentRequestParameters object.
    ConsentRequestParameters request = new ConsentRequestParameters
    {
        ConsentDebugSettings = debugSettings,
    };

    // Check the current consent information status.
    ConsentInformation.Update(request, OnConsentInfoUpdated);
}

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();

Examples on GitHub

See a full example of the UMP SDK integration covered in this page in HelloWorld.