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.
Installation#
Install the react-native-firebase package in your project.
Using NPM:
Using Yarn
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
Next, execute the plugin by adding the following to your /android/app/build.gradle file:
Lastly, execute the plugin by adding the following to your AndroidManifest.xml file:
Register User with FCM token#
Request Params#
| Status | Description | Type | Required |
|---|---|---|---|
USER_IDENTIFIER | Unique Id to Register the User | String | true |
FCM_TOKEN | Unique Id | String | false |
Response Params#
| Arguments | Description | Type |
|---|---|---|
| statusCode | Status Code | Number |
| message | Success/Error Message | String |
| data | Username and Password | Object |
Sample Response:#
Background Message Handling Configuration#
Please add the following code to your index.js file
Sample Response: