Push Notification Android and Firebase Cloud Messaging

Tram Ho

Firebase Cloud Messaging (FCM) is a cross-platform messaging solution from Google that allows sending messages reliably and for free.

Using FCM, we can send notification messages to client apps up to 4KB.

How does Firebase Push Notification work?

FCM implementation consists of two main components for sending and receiving:

  • A trusted environment like Firebase’s Cloud Function or an app server to build, target and send messages.
  • The iOS, Android or web client (JavaScript) receives messages via the transport service specific to each respective platform.

Integrate FCM into Android Project

Step 1 : Visit the Firebase Console page

Step 2 : Proceed to create a Project if you do not already have.

Step 3 : Choose a platform to get started.

Step 4 : Enter the package name of the Project and the SHA-1 code.

To get the SHA-1 code go to Android Studio -> Select the Gradle tab in the right bar -> Select app modules -> Tasks -> Android -> signing report

Step 5 : Download the google-services.json file and place it in the app module.

Step 6 : Integrate Firebase SDK

  • Add the file build.gradle Project:

  • Add file build.gradle Module App:

  • Carry out the Sync Project by clicking Sync now in Android Studio

Step 7 : Create a Service that inherits from FirebaseMessagingService to handle receiving messages from Firebase

Step 8 : Add the AndroidManifest.xml file

Send Push Notification using Firebase Console

Step 1 : Go to Firebase Console and select the created Project.

Step 2 : Select Cloud Messaging in the Left Menu.

Step 3 : Click New notification .

Step 4 : Enter the information of the notification and proceed to send.

Step 5 : Check the results on the device.


Invite you to read more at:



Share the news now

Source : Viblo