Firebase Cloud Messaging is new version of Google Cloud Messaging. Firebase Cloud Messaging (FCM) is powerful service with many new feature which help you to build better application communication. FCM is very easy to integrate as compared to GCM. Follow these simple step to integrate FCM in your application.


Create App in Firebase for FCM

Step 1. Go to Firebase console and create new project.

Step 2.  Create new project name your project and select country and click on create project.

Firebase Cloud Messaging (FCM) for Android App

Step 3. Now click on Add Firebase to your Android app and name your application package name and your system SHA1 here 

Firebase Cloud Messaging for Android App

Step 4.  Now once you complete above step google-services.json is automatically downloaded on your browser if not you can may download on link

Firebase Cloud Messaging for Android App

Now server part is complete you successfully create your first application on firebase server it time to create your android application and complete remaining.

Integrate Firebase Cloud Messaging in Android

Step 1. Create new android project name your project as you named when you create app in Firebase package name must be same.

Step 2. Open your project .gradle and add in it

Step 3. Now open app.gradle and add dependencies in it and also apply plugin in end as shown bellow code.

after this sync your project and also clean and rebuild your project.

Step 4. Now copy paste your google-services.json inside app folder as shown bellow image

Firebase Cloud Messaging (FCM) for Android App

Step 5. Now edit your Manifest file and add two service in it

Step 6. Now create two service you add in your manifest file

Also open your mainactivity file and add bellow code to display token on button press.

Now run your project on device and after you application open open android log and search for Refreshed token if every thing is fine you get your token as shown bellow image.

Set Up a Firebase Cloud Messaging for Android App

Send Notification from Firebase Cloud Messaging to Android App

Step 1. Go to your application console and click on notification and send new message 

Send notification from Firebase console android

Step 2. Type your message and enter your Token in it and click on send

Send FCM notification from console android

Step 3. Check your device you get notification

Send FCM to android application from console


Send Image Notification on FCM

To send image notification from server use below PHP Code

And in case of image we need to make some change on our service so use bellow code.

That’s all hope this help you to integrate FCM in your android application 🙂