ANDROID

How to Use Firebase Cloud Messaging for Android App

Push Notification also knows as Messaging service for android app is the best way for the app developer to be in contact with Application user. Firebase is recently launched by Google with a number of services, You can learn what is Google Firebase from link article. Firebase Cloud messaging service is alternative to old GCM and Firebase is far easy and simple to implement in Android App.

Firebase Cloud Messaging provide user dashboard to send the push notification with the different option like sending the notification to a single android device to the specific version of your deploy android app on Google Play store. In this Firebase Cloud Messaging Tutorial, you will learn how to implement Firebase Notification service in Android App developed in Android Studio and also how to send the push notification to single android devices using Firebase Cloud Messaging.  Here we start our tutorial, so fix your seat belts.

Firebase Cloud Messaging Tutorial

Firebase Cloud Messaging Tutorial

Firebase Cloud Messaging Tutorial

Creating Firebase Cloud Messaging account

Go to firebase console and create a new project.

Create Firebase Project For Android App

Create Firebase Project For Android App

Add your Firebase App name and select your country.

Firebase Android Notification Project

Firebase Android Notification Project

Now click on Add Firebase to your Android App

Add Firebase to Android App

Add Firebase to Android App

Create Android App for Firebase Cloud Notification

Start Android Studio and Configure Android App Project for Firebase cloud messaging service.

Create Android Firebase Cloud Messaging App

Create Android Firebase Cloud Messaging App

Now select the device for which you want to develop App and choose the lowest version for the supporting device. For Firebase cloud messaging service, there is no restriction of Android API, we can use any lowest version but it should support Google play services.

Copy package name of your android app project and now return to the Firebase Console and enter your package name as shown below. Note: you can leave Debug signing certificate SHA-1 as it is the optional option.

Add package name to Firebase Android App

Add package name to Firebase Android App

After clicking add app you will get google-services.JSON file.

How to Add Firebase Messaging to Your Project

Adding Firebase Messaging to Your Project

Adding Firebase Messaging to Your Project

As you are now in your android app project paste the file google-services.json to app folder of your project.

Now you have to make few changes in your root level build.gradle file by adding the following code.

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

Finally Sync Your Android Project.

Implementing Firebase Cloud Messaging

Create a class named MyFirebaseInstanceIDService.java and write the following code.

Now create MyFirebaseMessagingService.java 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.

Now sync your android project and start Emulator to check the project is working. If you use proper coding as I shown above then it will run without any error.

Sending Push Notification using Firebase Console

  • Go to firebase console and select the app you created.
  • From the left menu select notification.
  • Click on the 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

Hope you apply everything exactly as detailed in the tutorial, enjoy creating the new android app. If you have any suggestion or query then ping us.

Click to comment

Leave a Reply

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

Most Popular

Buzzing your life from assorted Coding,tips and general life opinion. Made your life Buzz by BuzzMyCode articles, share with world.

What is Buzzmycode, we had started this website to give tech savy the new way of life by reading our fresh organic content on every technology and applications.

Copyright © 2017 SyncSaS. Theme by SyncSaS Themes, powered by BuzzMyCode.

To Top