FirebaseInAppMessaging

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 Instance ID token to:

  • identify the app instance
  • fetch messages from the Firebase backend
  • send usage metrics to the Firebase backend.
To delete the Instance ID and the data associated with it, see deleteInstanceId().

Public Method Summary

boolean
areMessagesSuppressed()
Determine whether messages are suppressed or not.
static FirebaseInAppMessaging
getInstance()
Get FirebaseInAppMessaging instance using the firebase app returned by getInstance()
boolean
isAutomaticDataCollectionEnabled()
Determine whether automatic data collection is enabled or not
void
setAutomaticDataCollectionEnabled(boolean isAutomaticCollectionEnabled)
Enable or disable automatic data collection for Firebase In-App Messaging.
void
setMessagesSuppressed(Boolean areMessagesSuppressed)
Enable or disable 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.

Inherited Method Summary

Public Methods

public boolean areMessagesSuppressed ()

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

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

public boolean isAutomaticDataCollectionEnabled ()

Determine whether automatic data collection is enabled or not

Returns
  • true if auto initialization is required

public void setAutomaticDataCollectionEnabled (boolean isAutomaticCollectionEnabled)

Enable or disable 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 deleteInstanceId() 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 setMessagesSuppressed (Boolean areMessagesSuppressed)

Enable or disable 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