Firebase Cloud Messaging Tutorial for Android


Firebase Cloud Messaging (FCM) is a cross-platform messaging solution that lets you reliably deliver messages at no cost.

Using FCM, you can notify a client app that new email or other data is available to sync. You can send notification messages to drive user re-engagement and retention. For use cases such as instant messaging, a message can transfer a payload of up to 4KB to a client app.

Creating an Android Studio Project

Creating an Android Project once the project is created copy the package name then go to developer console with below link and their create a project with same package


Now put your app name and select your country.


Now click on Add Firebase to Your Android App.


Now you have to enter your projects package name and click on ADD APP.


fter clicking add app you will get google-services.json file.
Adding Firebase Messaging to Your Project
Now come back to your android project. Go to app folder and paste google-services.json file.


Now go to your root level build.gradle file and add the following code.

Inside app level build.gradle file make the following changes.

Now sync your project.
Implementing Firebase Cloud Messaging

Create a class named and write the following code.

Now create and write the following code.

Now we have to define the above services in our AndroidManifest.xml file. So go to manifest and modify as follows.

Thats all. Now run your app .
After running you will see the token in the logcat. Copy the token.


Sending Push Notification using Firebase Console
Go to firebase console and select the app you created.
From the left menu select notification.
Click on new message.
Enter message, select single device and paste the token you copied and click on send. The same as I did on the video, and check your device



Leave a Reply