Firebase Notification Integration in React Native Android Application

Updated 5 March 2021

Save

In this blog, we will learn about how to integrate and receive firebase notification in React Native Android App.

Having Notifications in your mobile applications is one of the basic features these days.

Firebase provides many cool functions that make application development, testing and analytics super easy.

But personally, I feel that there is no competition for firebase in terms of Push Notifications and it will soon be the only way to send notifications to your mobile application users.

Well, there can be many separate blogs for each of the firebase related functionality.

Currently, we will focus on firebase push notification only.

Integrating this super easy, but procedural, please follow through the lines written along.

So, without wasting further time, let’s get started.

Things You Need To Get Started :

Installation Steps :

Above command will install and save the react-native-firebase package in your React Native Project.

This Command will link the react-native-firebase package in your React Native Project.

Before You Start Coding

Now go to your firebase console and set up your android package and app registration over there.

Download the google-services.json file and keep it safe with you.

Now, you need to do some manual changes in your android directory/folder of your React Native Project.

Paste the google-services.json file that you just saved above at path android –> app

Your directory will look something like this :

 

 

In your project level build.gradle file (path to this file: android –> build.gradle )

In your module level build.gradle file (path to this file: android–> app–>build.gradle)

Now you need to make some changes in your AndroidManifest.xml file

NOTE : -> You need to add default notification_icon in your android drawable folders only so that the default notification icon is replaced by the icon you want to use.

CODE :

After following the above steps you now need to add and remove some simple listeners to your React native App.js File.

After adding these listeners, we now need to handle the Notification received, so we will just modify our listeners a bit like below :

And It is done, you will now be able to receive notifications in your React Native Android Application.

Below is a snippet of App.js file with all the changes –>

 

Hope This helps you.

Keep coding and Keep Sharing 🙂

References : –>

 

 

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


15 comments

  • Chirag ncrypted
    • anchit (Moderator)
  • Jimmy
    • anchit (Moderator)
  • Asish
  • Rajesh De
    • Rajesh De
      • anchit (Moderator)
  • zaki
    • anchit (Moderator)
  • Deepak Govindarajan
    • Bishwajeet Das
      • anchit (Moderator)
  • Bishwajeet Das
    • anchit (Moderator)
  • Start a Project


      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home