Android Firebase edit

Demo of FCM based notifications

This example shows how to use the Firebase Cloud Messaging(FCM) platform. FCM is a successor of Google Cloud Messaging(GCM). It does not require C2D_MESSAGE permissions from the app users.

Steps to integrate FCM are as follows.

  1. Create sample hello world project in Android Studio Your Android studio screen would look like the following picture.
  2. Next step is to set up firebase project. Visit and create a project with an identical name, so that you can track it easily.
  3. Now it is time to add firebase to your sample android project you have just created. You will need package name of your project and Debug signing certificate SHA-1(optional).
a. Package name - It can be found from the android manifest XML file.

b. Debug signing SHA-1 certificate - It can be found by running following command in the terminal.

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

Enter this information in the firebase console and add the app to firebase project. Once you click on add app button, your browser would automatically download a JSON file named “google-services.json”.

  1. Now copy the google-services.json file you have just downloaded into your Android app module root directory.
  2. Follow the instructions given on the firebase console as you proceed ahead.
a. Add following code line to your project level build.gradle

    classpath '' .....`

b. Add following code line at the end of your app level build.gradle.
        //following are the dependencies to be added
        compile ''
        compile ''
    // this line goes to the end of the file
    apply plugin: ''

c. Android studio would ask you to sync project. Click on Sync now.
  1. Next task is to add two services.
a. One extending FirebaseMessagingService with intent-filter as following

            <action android:name=""/>
b. One extending FirebaseInstanceIDService.
        <action android:name=""/>
  1. FirebaseMessagingService code should look like this.
import android.content.Intent;
import android.os.IBinder;


public class MyFirebaseMessagingService extends FirebaseMessagingService {
    public MyFirebaseMessagingService() {
  1. FirebaseInstanceIdService should look like this.
import android.content.Intent;
import android.os.IBinder;


public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {
    public MyFirebaseInstanceIDService() {
  1. Now it is time to capture the device registration token. Add following line of code to MainActivity’s onCreate method.
String token = FirebaseInstanceId.getInstance().getToken();
Log.d("FCMAPP", "Token is "+token);
  1. Once we have the access token, we can use firebase console to send out the notification. Run the app on your android handset.

Click on Notification in Firebase console and UI will help you to send out your first message. Firebase offers functionality to send messages to single device(By using the device token id we captured) or all the users using our app or to specific group of users. Once you send your first message, your mobile screen should look like following.

Thank you

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents
64 Menu
100 Firebase
112 Loader
119 Xposed
132 Colors
135 Fresco
140 AdMob
147 Button
156 Vk SDK
170 XMPP
176 OpenCV
200 FileIO
203 Moshi
217 Paint
231 AIDL
241 JCodec
243 Okio
255 Looper
  ↑ ↓ to navigate     ↵ to select     Esc to close