Push Notification

Integrate FireBase to the Application#

Step 1: Create Project in the firebase console using your app package name. Ex: com.testapp

Step 2: After the project creation download the google-service.json file which is automatically generated.

Step 3: Add the google-service.json file to your android Application with in the /android/app/ folder.


Install the react-native-firebase package in your project.

Using NPM:

npm install --save @react-native-firebase/app @react-native-firebase/messaging

Using Yarn

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

Configure Firebase in Android:#

To allow Firebase on Android to use the credentials, the google-services plugin must be enabled on the project. This requires modification to two files in the Android directory.

First, add the google-services plugin as a dependency inside of your /android/build.gradle file

buildscript {
dependencies {
// ... other dependencies
classpath ("com.google.gms:google-services:4.3.15")
// Add me --- /\

Next, execute the plugin by adding the following to your /android/app/build.gradle file:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services' // <- Add this line

Lastly, execute the plugin by adding the following to your AndroidManifest.xml file:

<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

Register User with FCM token#

import messaging from '@react-native-firebase/messaging';
const fcmToken = await messaging().getToken();
const registerResponse = await mirrorflyRegister({
userIdentifier: '917********4',
fcmToken: "",

Request Params#

USER_IDENTIFIERUnique Id to Register the UserStringtrue
FCM_TOKENUnique IdStringfalse

Note : Unique ID assigned for each user Ex: 12345678 (any alphanumeric). The below characters is not allowed in userId: U+0022 (") U+0026 (&) U+0027 (') U+002F (/) U+003A (:) U+003C (<) U+003E (>) U+0040 (@) userID should follow below specification: https://xmpp.org/extensions/xep-0106.html

Response Params#

statusCodeStatus CodeNumber
messageSuccess/Error MessageString
jidUser JidString

Sample Response:#

Example Response#

"jid": "917********4@domain",
"message": "Login Success",
"statusCode": 200

Background Message Handling Configuration#

Sample code to setup index.js.#
import {AppResgistry} from 'react-native';
// add the below imports
import { mirrorflyNotificationHandler, setupCallScreen } from 'mirrorfly-uikit-react-native';
import messaging from '@react-native-firebase/messaging';
// add setBackgroundMessageHandler for background/killed state notification
messaging().setBackgroundMessageHandler(message => {
let API_URL = 'API_URL';
let lisenceKey = 'lisenceKey' ;
let remoteMessageData = {
remoteMessage: message,
apiBaseurl: API_URL,
licenseKey: lisenceKey,