UserMessagingPlatform

public final class UserMessagingPlatform


Entry point for the User Messaging Platform SDK.

Summary

Nested types

Interface definition for a callback to be invoked when a consent form failed to load.

Interface definition for a callback to be invoked when a consent form loads successfully.

Public methods

static ConsentInformation

Gets the ConsentInformation.

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

Loads a consent form and immediately shows it from the provided Activity if getConsentStatus is REQUIRED.

static void

Loads a ConsentForm.

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

Presents a privacy options form from the provided Activity if getPrivacyOptionsRequirementStatus is REQUIRED.

Public methods

getConsentInformation

public static ConsentInformation getConsentInformation(Context context)

Gets the ConsentInformation.

loadAndShowConsentFormIfRequired

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

Loads a consent form and immediately shows it from the provided Activity if getConsentStatus is REQUIRED.

Calls 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 FormError
  • the form fails to show, returning a non-null FormError

This method must be called on the main thread.

Parameters
Activity activity

The activity showing the consent form.

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

Checks that isConsentFormAvailable returns true prior to calling this method.

This method must be called on the main thread.

Parameters
Context context

The context.

UserMessagingPlatform.OnConsentFormLoadSuccessListener successListener

The consent form load success listener.

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 getPrivacyOptionsRequirementStatus is 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.

OnConsentFormDismissedListener is called after the user is presented with a form, selects an option, and dismisses the form.

OnConsentFormDismissedListener may also return asynchronously on the next run loop with a non-null 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
Activity activity

The activity showing the privacy options form.

ConsentForm.OnConsentFormDismissedListener onConsentFormDismissedListener

The listener that gets called when the privacy options form is dismissed.