# UserMessagingPlatform

# UserMessagingPlatform


```
public final class UserMessagingPlatform
```

<br />

*** ** * ** ***

Entry point for the User Messaging Platform SDK.

## Summary

| ### Nested types |
|---|
| `public interface https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/UserMessagingPlatform.OnConsentFormLoadFailureListener` Interface definition for a callback to be invoked when a consent form failed to load. |
| `public interface https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/UserMessagingPlatform.OnConsentFormLoadSuccessListener` Interface definition for a callback to be invoked when a consent form loads successfully. |

| ### Public methods |
|---|---|
| `static https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/ConsentInformation` | `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/UserMessagingPlatform#getConsentInformation(android.content.Context)(https://developer.android.com/reference/android/content/Context.html context)` Gets the `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/ConsentInformation`. |
| `static void` | `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/UserMessagingPlatform#loadAndShowConsentFormIfRequired(android.app.Activity,com.google.android.ump.ConsentForm.OnConsentFormDismissedListener)( https://developer.android.com/reference/android/app/Activity.html activity, https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/ConsentForm.OnConsentFormDismissedListener onConsentFormDismissedListener )` Loads a consent form and immediately shows it from the provided `Activity` if `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/ConsentInformation#getConsentStatus()` is `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/ConsentInformation.ConsentStatus#REQUIRED()`. |
| `static void` | `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/UserMessagingPlatform#loadConsentForm(android.content.Context,com.google.android.ump.UserMessagingPlatform.OnConsentFormLoadSuccessListener,com.google.android.ump.UserMessagingPlatform.OnConsentFormLoadFailureListener)( https://developer.android.com/reference/android/content/Context.html context, https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/UserMessagingPlatform.OnConsentFormLoadSuccessListener successListener, https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/UserMessagingPlatform.OnConsentFormLoadFailureListener failureListener )` Loads a `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/ConsentForm`. |
| `static void` | `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/UserMessagingPlatform#showPrivacyOptionsForm(android.app.Activity,com.google.android.ump.ConsentForm.OnConsentFormDismissedListener)( https://developer.android.com/reference/android/app/Activity.html activity, https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/ConsentForm.OnConsentFormDismissedListener onConsentFormDismissedListener )` Presents a privacy options form from the provided `Activity` if `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/ConsentInformation#getPrivacyOptionsRequirementStatus()` is `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/ConsentInformation.PrivacyOptionsRequirementStatus#REQUIRED`. |

## Public methods

### getConsentInformation

```
public static ConsentInformation getConsentInformation(Context context)
```

Gets the `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/ConsentInformation`.

### loadAndShowConsentFormIfRequired

```
public static void loadAndShowConsentFormIfRequired(
    Activity activity,
    ConsentForm.OnConsentFormDismissedListener onConsentFormDismissedListener
)
```

Loads a consent form and immediately shows it from the provided `Activity` if `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/ConsentInformation#getConsentStatus()` is `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/ConsentInformation.ConsentStatus#REQUIRED()`.

Calls `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/ConsentForm.OnConsentFormDismissedListener` when this method finishes, which may occur due to one of the following:

- the user is presented with the form, selects an option, and dismisses the form
- the form is not required to show
- the form fails to load, returning a non-null `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/FormError`
- the form fails to show, returning a non-null `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/FormError`

This method must be called on the main thread.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/app/Activity.html activity` | The activity showing the consent form. |
| `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/ConsentForm.OnConsentFormDismissedListener onConsentFormDismissedListener` | The listener that gets called when the consent form is dismissed. |

### loadConsentForm

```
public static void loadConsentForm(
    Context context,
    UserMessagingPlatform.OnConsentFormLoadSuccessListener successListener,
    UserMessagingPlatform.OnConsentFormLoadFailureListener failureListener
)
```

Loads a `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/ConsentForm`.

Checks that `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/ConsentInformation#isConsentFormAvailable()` returns `true` prior to calling this method.

This method must be called on the main thread.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | The context. |
| `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/UserMessagingPlatform.OnConsentFormLoadSuccessListener successListener` | The consent form load success listener. |
| `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/UserMessagingPlatform.OnConsentFormLoadFailureListener failureListener` | The consent form load failure listener. |

### showPrivacyOptionsForm

```
public static void showPrivacyOptionsForm(
    Activity activity,
    ConsentForm.OnConsentFormDismissedListener onConsentFormDismissedListener
)
```

Presents a privacy options form from the provided `Activity` if `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/ConsentInformation#getPrivacyOptionsRequirementStatus()` is `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/ConsentInformation.PrivacyOptionsRequirementStatus#REQUIRED`.

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

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.

`https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/ConsentForm.OnConsentFormDismissedListener` is called after the user is presented with a form, selects an option, and dismisses the form.

`https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/ConsentForm.OnConsentFormDismissedListener` may also return asynchronously on the next run loop with a non-null `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/FormError` under one of the following error conditions:

- the form is not available
- the form fails to show
- the form is still being preloaded

This method must be called on the main thread.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/app/Activity.html activity` | The activity showing the privacy options form. |
| `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/android/privacy/api/reference/com/google/android/ump/ConsentForm.OnConsentFormDismissedListener onConsentFormDismissedListener` | The listener that gets called when the privacy options form is dismissed. |