Firebase Cloud Messaging Android Studio Tutorial

You will need to work with Firebase Cloud Messaging Android example(FCM) for adding push notifications in android app.

Firebase Cloud Messaging Android Studio Tutorial guide you to integrate firebase push notification(FCM) in android studio.

In this Firebase Cloud Messaging Android Studio Tutorial, we will send notification from firebase console.

If you want to send notification from server(PHP-MySQL), then check Firebase push notification Android tutorial. 

If you want to send notification to multiple Android devices then check Android Firebase Push notification to multiple devices.

First, check output then we will develop Firebase Cloud Messaging Android Studio example(FCM).

Step 1: Create a new project in Android Studio.

If you select default activity as an empty activity while creating new project in android studio, it will be great choice.

Step 2: Creating app in Firebase Console

I have developed a video about how to make an app in the firebase console.

Quick steps of above video

  1. Go to and sign in to your google account.
  2. Click on Add Project and give project name and country.
  3. Click on CREATE PROJECT button.
  4. After project is created, click on Add firebase to your Android app button.
  5. Give your Android package name and click on Register App button.
  6. Click on Download google-services.json button.
  7. Move your downloaded JSON file into app folder of your android project as shown in the video.

Step 3: Updating build.gradle(Project: project_name) file:

we need to add following in dependencies{} structure

So final code for build.gradle(Project: project_name)  will look like this:

Step 4: Updating build.gradle(Module:app) file

Add following code into dependencies{}

Add following at the end of the file

Final code for build.gradle(Module:app)

Step 5: Creating Service Classes

Creating GettingDeviceTokenService

Create a new JAVA class named GettingDeviceTokenService”  and add below source code

  • In this service, we will get device token.

Creating NotificationService

Create a new JAVA class named NotificationService” and add below source code

  • We will receive message in this service.
  • You can also control title,icon, vibration, message tone etc. in this service.

Step 6: Updating AndroidManifest.xml

Add internet permission in AndroidManifest.xml 

Add services into <application> … </application> tags

Final code for AndroidManifest.xml 

Step 7: Time to getting Notification

  • As you have seen in output video at the starting of the tutorial, get device token from logcat.
  • Now go to the firebase console and select your project.
  • Click on Notification from left menu bar.
  • Now type your message and select single device in Target.
  • Put device token into the FCM registration token field and click on Send Message -> Send
  • and…. ya you have push notification same as getting in WhatsApp or other app.

Feel free ask your questions and queries in comment section.

So all for firebase cloud messaging Android Studio programmatically example tutorial. Thank you.

Download Source Code For Firebase Cloud Messaging Android

[sociallocker]SimpleFCM [/sociallocker]

Hardik Parsania

I am mobile app developer. I am always passionate about solving complex and real world problems.I have developed many apps with great interest and superior logical skills.

You may also like...

4 Responses

  1. emon says:

    nice tutorial.but i want to send notification one to several selected can i achieve this?

  2. Tam Brown says:

    Very good tut, but how do I add images in message?

Leave a Reply

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