Files
react-native-firebase/docs/in-app-messaging/quick-start.md
2019-08-21 10:07:13 +01:00

1.9 KiB

title, description
title description
Firebase In-App Messaging Quick Start Getting started with Firebase In-App Messaging in React Native Firebase

Firebase In-App Messaging Quick Start

Installation

Install this module with Yarn:

yarn add @react-native-firebase/in-app-messaging

Integrating manually and not via React Native auto-linking? Check the setup instructions for Android & iOS.

Module usage

Once installed, any published campaigns from the Firebase console are automatically handled and displayed on your users device. The module provides a JavaScript API to allow greater control of the displaying of these messages.

Once installed, import the FIAM package into your project:

import inAppMessaging from '@react-native-firebase/in-app-messaging';

The package also provides access to the firebase instance:

import { firebase } from '@react-native-firebase/in-app-messaging';

Suppressing messages

The Firebase console campaign manager provides a few events to handle when messages are displayed to users. In some situations you may want to handle this manually to only display messages at a chosen time, for example once a user has completed an on-boarding process within your app. The setMessagesDisplaySuppressed method can be used to achieve this.

The suppressed state is not persisted between restarts, so ensure it is called as early as possible.

import inAppMessaging from '@react-native-firebase/in-app-messaging';

async function bootstrap() {
  await inAppMessaging().setMessagesDisplaySuppressed(true);
}

async function onSetup(user) {
  await setupUser(user);
  // Allow user to receive messages now setup is complete
  inAppMessaging().setMessagesDisplaySuppressed(false);
}