firebase::ump::ConsentInfo

#include <consent_info.h>

Consent Information class for the User Messaging Platform SDK.

Summary

The User Messaging Platform (UMP) SDK is Google’s option to handle user privacy and consent in mobile apps.

This class contains all of the methods necessary for obtaining consent from the user.

Constructors and Destructors

~ConsentInfo()
Shut down the User Messaging Platform Consent SDK.

Public functions

CanRequestAds()
bool
Indicates whether the app has completed the necessary steps for gathering updated user consent.
GetConsentFormStatus()
Consent form status.
GetConsentStatus()
The user’s consent status.
GetPrivacyOptionsRequirementStatus()
Check whether the privacy options form needs to be displayed.
LoadAndShowConsentFormIfRequired(FormParent parent)
Future< void >
Loads a consent form and immediately presents it using the given FormParent, if ConsentStatus is kConsentStatusRequired.
LoadAndShowConsentFormIfRequiredLastResult()
Future< void >
Get theFuture from the most recent call toLoadAndShowConsentFormIfRequired().
LoadConsentForm()
Future< void >
Loads a consent form.
LoadConsentFormLastResult()
Future< void >
Get theFuture from the most recent call toLoadConsentForm().
RequestConsentInfoUpdate(constConsentRequestParameters & params)
Future< void >
Requests consent information update.
RequestConsentInfoUpdateLastResult()
Future< void >
Get theFuture from the most recent call toRequestConsentInfoUpdate().
Reset()
void
Clears all consent state from persistent storage.
ShowConsentForm(FormParent parent)
Future< void >
Presents the full screen consent form using the given FormParent, which is defined as an Activity on Android and a UIViewController on iOS.
ShowConsentFormLastResult()
Future< void >
Get theFuture from the most recent call toShowConsentForm().
ShowPrivacyOptionsForm(FormParent parent)
Future< void >
IfGetPrivacyOptionsRequirementStatus() is kPrivacyOptionsRequirementStatusRequired, presents a privacy options form from the provided FormParent, which is defined as an Activity on Android and a UIViewController on iOS.
ShowPrivacyOptionsFormLastResult()
Future< void >
Get theFuture from the most recent call toShowPrivacyOptionsForm().

Public static functions

GetInstance(const ::firebase::App & app,InitResult *init_result_out)
Initializes the User Messaging Platform Consent SDK.
GetInstance(JNIEnv *jni_env, jobject activity,InitResult *init_result_out)
Initializes the User Messaging Platform Consent SDK without Firebase for Android.
GetInstance(InitResult *init_result_out)
Initializes User Messaging Platform for iOS without Firebase.

Public functions

CanRequestAds

boolCanRequestAds()

Indicates whether the app has completed the necessary steps for gathering updated user consent.

Returns true ifRequestConsentInfoUpdate() has been called and GetConsentStatus returns either kConsentStatusNotRequired or kConsentStatusObtained.

GetConsentFormStatus

ConsentFormStatusGetConsentFormStatus()

Consent form status.

This value defaults to kConsentFormStatusUnknown and requires a call toRequestConsentInfoUpdate() to update.

GetConsentStatus

ConsentStatusGetConsentStatus()

The user’s consent status.

This value defaults to kConsentStatusUnknown untilRequestConsentInfoUpdate() is called, and defaults to the previous session’s value untilRequestConsentInfoUpdate() completes.

GetPrivacyOptionsRequirementStatus

PrivacyOptionsRequirementStatusGetPrivacyOptionsRequirementStatus()

Check whether the privacy options form needs to be displayed.

This is updated byRequestConsentInfoUpdate().

LoadAndShowConsentFormIfRequired

Future<void>LoadAndShowConsentFormIfRequired(FormParentparent)

Loads a consent form and immediately presents it using the given FormParent, if ConsentStatus is kConsentStatusRequired.

The FormParent is defined as an Activity on Android and a UIViewController on iOS. TheFuture will be completed successfully after the user selects an option (and the form is dismissed), or if the form is not required. TheFuture will be completed with an error if the form fails to load or show.

GetConsentStatus() andCanRequestAds() will be updated prior to theFuture being completed.

Details
Parameters
parent
A FormParent, which is an Activity object on Android and a UIViewController object on iOS.

LoadAndShowConsentFormIfRequiredLastResult

Future<void>LoadAndShowConsentFormIfRequiredLastResult()

Get theFuture from the most recent call toLoadAndShowConsentFormIfRequired().

LoadConsentForm

Future<void>LoadConsentForm()

Loads a consent form.

Returns an error if the consent form is unavailable or cannot be loaded.

LoadConsentFormLastResult

Future<void>LoadConsentFormLastResult()

Get theFuture from the most recent call toLoadConsentForm().

RequestConsentInfoUpdate

Future<void>RequestConsentInfoUpdate(constConsentRequestParameters&params)

Requests consent information update.

Must be called in every app session before checking the user’s consent status or loading a consent form. After calling this method,GetConsentStatus() andCanRequestAds() will be updated immediately to hold the consent state from the previous app session, if one exists.GetConsentStatus() andCanRequestAds() may be updated again immediately before the returned future is completed.

RequestConsentInfoUpdateLastResult

Future<void>RequestConsentInfoUpdateLastResult()

Get theFuture from the most recent call toRequestConsentInfoUpdate().

Reset

voidReset()

Clears all consent state from persistent storage.

This can be used in development to simulate a new installation.

ShowConsentForm

Future<void>ShowConsentForm(FormParentparent)

Presents the full screen consent form using the given FormParent, which is defined as an Activity on Android and a UIViewController on iOS.

The form will be dismissed and theFuture will be completed after the user selects an option.

GetConsentStatus() andCanRequestAds() are updated when the returnedFuture is completed.

Note: You must callLoadConsentForm() and wait for it to complete before calling this method.

Details
Parameters
parent
A FormParent, which is an Activity object on Android and a UIViewController object on iOS.

ShowConsentFormLastResult

Future<void>ShowConsentFormLastResult()

Get theFuture from the most recent call toShowConsentForm().

ShowPrivacyOptionsForm

Future<void>ShowPrivacyOptionsForm(FormParentparent)

IfGetPrivacyOptionsRequirementStatus() is kPrivacyOptionsRequirementStatusRequired, presents a privacy options form from the provided FormParent, which is defined as an Activity on Android and a UIViewController on iOS.

This method should only be called in response to a user input to request a privacy options form to be shown.

The future completes when the user selects an option and dismisses the form or is completed immediately with an error code if no form is presented. The privacy options form is preloaded by the SDK automatically when a form becomes available. If no form has been preloaded, the SDK will try to load one asynchronously.

Details
Parameters
parent
A FormParent, which is an Activity object on Android and a UIViewController object on iOS.

ShowPrivacyOptionsFormLastResult

Future<void>ShowPrivacyOptionsFormLastResult()

Get theFuture from the most recent call toShowPrivacyOptionsForm().

~ConsentInfo

~ConsentInfo()

Shut down the User Messaging Platform Consent SDK.

Public static functions

GetInstance

ConsentInfo*GetInstance(const::firebase::App&app,InitResult*init_result_out)

Initializes the User Messaging Platform Consent SDK.

Details
Parameters
app
Any FirebaseApp instance.
init_result_out
Optional: If provided, write the basic init result here. kInitResultSuccess if initialization succeeded, or kInitResultFailedMissingDependency on Android if there are Android dependencies missing.
Returns
A pointer to theConsentInfo instance if UMP was successfully initialized, nullptr otherwise. Each call toGetInstance() will return the same pointer; when you are finished using the SDK, you can delete the pointer and the UMP SDK will shut down.

GetInstance

ConsentInfo*GetInstance(JNIEnv*jni_env,jobjectactivity,InitResult*init_result_out)

Initializes the User Messaging Platform Consent SDK without Firebase for Android.

The arguments toGetInstance() are platform-specific so the caller must do something like this:

#if defined(__ANDROID__)consent_info=firebase::ump::ConsentInfo::GetInstance(jni_env,activity);#elseconsent_info=firebase::ump::GetInstance();#endif

Details
Parameters
jni_env
JNIEnv pointer.
activity
Activity used to start the application.
init_result_out
Optional: If provided, write the basic init result here. kInitResultSuccess if initialization succeeded, or kInitResultFailedMissingDependency on Android if there are Android dependencies missing.
Returns
A pointer to theConsentInfo instance if UMP was successfully initialized, nullptr otherwise. Each call toGetInstance() will return the same pointer; when you are finished using the SDK, you can delete the pointer and the UMP SDK will shut down.

GetInstance

ConsentInfo*GetInstance(InitResult*init_result_out)

Initializes User Messaging Platform for iOS without Firebase.

Note: Once any overload ofConsentInfo::GetInstance has been called, you can use this method to obtain the same instance again.

Details
Parameters
init_result_out
Optional: If provided, write the basic init result here. kInitResultSuccess if initialization succeeded, or kInitResultFailedMissingDependency if a dependency is missing. On iOS, this will always return kInitResultSuccess, as missing dependencies would have caused a linker error at build time.
Returns
A pointer to theConsentInfo instance. Each call toGetInstance() will return the same pointer; when you are finished using the SDK, you can delete the pointer, and the UMP SDK will shut down.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-06-10 UTC.