public class FirebaseInAppMessaging extends Object

The entry point of the Firebase In App Messaging headless SDK.

Firebase In-App Messaging will automatically initialize, and start listening for events.

This feature uses a Firebase Installation ID token to:

To delete the Installation ID and the data associated with it, see delete().

Public Method Summary

void
addClickListener(FirebaseInAppMessagingClickListener clickListener)
Registers a click listener with FIAM, which will be notified on every FIAM click.
void
addClickListener(FirebaseInAppMessagingClickListener clickListener, Executor executor)
Registers a click listener with FIAM, which will be notified on every FIAM click, and triggered on the provided executor.
void
addDismissListener(FirebaseInAppMessagingDismissListener dismissListener)
Registers a dismiss listener with FIAM, which will be notified on every FIAM dismiss.
void
addDismissListener(FirebaseInAppMessagingDismissListener dismissListener, Executor executor)
Registers a dismiss listener with FIAM, which will be notified on every FIAM dismiss, and triggered on the provided executor.
void
addDisplayErrorListener(FirebaseInAppMessagingDisplayErrorListener displayErrorListener)
Registers a display error listener with FIAM, which will be notified on every FIAM display error.
void
addDisplayErrorListener(FirebaseInAppMessagingDisplayErrorListener displayErrorListener, Executor executor)
Registers a display error listener with FIAM, which will be notified on every FIAM display error, and triggered on the provided executor.
void
addImpressionListener(FirebaseInAppMessagingImpressionListener impressionListener)
Registers an impression listener with FIAM, which will be notified on every FIAM impression.
void
addImpressionListener(FirebaseInAppMessagingImpressionListener impressionListener, Executor executor)
Registers an impression listener with FIAM, which will be notified on every FIAM impression, and triggered on the provided executor.
boolean
areMessagesSuppressed()
Determines whether messages are suppressed or not.
static FirebaseInAppMessaging
getInstance()
Gets FirebaseInAppMessaging instance using the firebase app returned by getInstance()
boolean
isAutomaticDataCollectionEnabled()
Determines whether automatic data collection is enabled or not.
void
removeClickListener(FirebaseInAppMessagingClickListener clickListener)
Unregisters a click listener.
void
removeDisplayErrorListener(FirebaseInAppMessagingDisplayErrorListener displayErrorListener)
Unregisters a display error listener.
void
removeImpressionListener(FirebaseInAppMessagingImpressionListener impressionListener)
Unregisters an impression listener.
void
setAutomaticDataCollectionEnabled(boolean isAutomaticCollectionEnabled)
Enables, disables, or clears automatic data collection for Firebase In-App Messaging.
void
setAutomaticDataCollectionEnabled(Boolean isAutomaticCollectionEnabled)
Enables, disables, or clears automatic data collection for Firebase In-App Messaging.
void
setMessageDisplayComponent(FirebaseInAppMessagingDisplay messageDisplay)
Sets message display component for FIAM SDK.
void
setMessagesSuppressed(Boolean areMessagesSuppressed)
Enables or disables suppression of Firebase In App Messaging messages.
void
triggerEvent(String eventName)
Programmatically triggers a contextual trigger.

Inherited Method Summary

Public Methods

public void addClickListener (FirebaseInAppMessagingClickListener clickListener)

Registers a click listener with FIAM, which will be notified on every FIAM click.

public void addClickListener (FirebaseInAppMessagingClickListener clickListener, Executor executor)

Registers a click listener with FIAM, which will be notified on every FIAM click, and triggered on the provided executor.

public void addDismissListener (FirebaseInAppMessagingDismissListener dismissListener)

Registers a dismiss listener with FIAM, which will be notified on every FIAM dismiss.

public void addDismissListener (FirebaseInAppMessagingDismissListener dismissListener, Executor executor)

Registers a dismiss listener with FIAM, which will be notified on every FIAM dismiss, and triggered on the provided executor.

public void addDisplayErrorListener (FirebaseInAppMessagingDisplayErrorListener displayErrorListener)

Registers a display error listener with FIAM, which will be notified on every FIAM display error.

public void addDisplayErrorListener (FirebaseInAppMessagingDisplayErrorListener displayErrorListener, Executor executor)

Registers a display error listener with FIAM, which will be notified on every FIAM display error, and triggered on the provided executor.

public void addImpressionListener (FirebaseInAppMessagingImpressionListener impressionListener)

Registers an impression listener with FIAM, which will be notified on every FIAM impression.

public void addImpressionListener (FirebaseInAppMessagingImpressionListener impressionListener, Executor executor)

Registers an impression listener with FIAM, which will be notified on every FIAM impression, and triggered on the provided executor.

public boolean areMessagesSuppressed ()

Determines whether messages are suppressed or not. This is honored by the UI sdk, which handles rendering the in app message.

Returns
  • true if messages should be suppressed

public static FirebaseInAppMessaging getInstance ()

Gets FirebaseInAppMessaging instance using the firebase app returned by getInstance()

public boolean isAutomaticDataCollectionEnabled ()

Determines whether automatic data collection is enabled or not.

Returns
  • true if auto initialization is required

public void removeClickListener (FirebaseInAppMessagingClickListener clickListener)

Unregisters a click listener.

public void removeDisplayErrorListener (FirebaseInAppMessagingDisplayErrorListener displayErrorListener)

Unregisters a display error listener.

public void removeImpressionListener (FirebaseInAppMessagingImpressionListener impressionListener)

Unregisters an impression listener.

public void setAutomaticDataCollectionEnabled (boolean isAutomaticCollectionEnabled)

Enables, disables, or clears automatic data collection for Firebase In-App Messaging.

When enabled, generates a registration token on app startup if there is no valid one and generates a new token when it is deleted (which prevents delete() from stopping the periodic sending of data). This setting is persisted across app restarts and overrides the setting specified in your manifest.

By default, auto-initialization is enabled. If you need to change the default, (for example, because you want to prompt the user before generates/refreshes a registration token on app startup), add to your application’s manifest:

<meta-data android:name="firebase_inapp_messaging_auto_init_enabled" android:value="false" />
 

Note, this will require you to manually initialize Firebase In-App Messaging, via:

FirebaseInAppMessaging.getInstance().setAutomaticDataCollectionEnabled(true)

Parameters
isAutomaticCollectionEnabled Whether isEnabled

public void setAutomaticDataCollectionEnabled (Boolean isAutomaticCollectionEnabled)

Enables, disables, or clears automatic data collection for Firebase In-App Messaging.

When enabled, generates a registration token on app startup if there is no valid one and generates a new token when it is deleted (which prevents delete() from stopping the periodic sending of data). This setting is persisted across app restarts and overrides the setting specified in your manifest.

When null, the enablement of the auto-initialization depends on the manifest and then on the global enablement setting in this order. If none of these settings are present then it is enabled by default.

If you need to change the default, (for example, because you want to prompt the user before generates/refreshes a registration token on app startup), add the following to your application’s manifest:

<meta-data android:name="firebase_inapp_messaging_auto_init_enabled" android:value="false" />
 

Note, this will require you to manually initialize Firebase In-App Messaging, via:

FirebaseInAppMessaging.getInstance().setAutomaticDataCollectionEnabled(true)

Manual initialization will also be required in order to clear these settings and fall back on other settings, via:

FirebaseInAppMessaging.getInstance().setAutomaticDataCollectionEnabled(null)

Parameters
isAutomaticCollectionEnabled Whether isEnabled

public void setMessageDisplayComponent (FirebaseInAppMessagingDisplay messageDisplay)

Sets message display component for FIAM SDK. This is the method used by both the default FIAM display SDK or any app wanting to customize the message display.

Parameters
messageDisplay

public void setMessagesSuppressed (Boolean areMessagesSuppressed)

Enables or disables suppression of Firebase In App Messaging messages.

When enabled, no in app messages will be rendered until either you either disable suppression, or the app restarts, as this state is not preserved over app restarts.

By default, messages are not suppressed.

Parameters
areMessagesSuppressed Whether messages should be suppressed

public void triggerEvent (String eventName)

Programmatically triggers a contextual trigger. This will display any eligible in-app messages that are triggered by this event.