Firebase Push Notification From App Server

By | May 6, 2018

You can send message from server to device with firebase “FCM Server”.

First go to firebase console and create new project.

After that you can follow this steps.

Push Notification with Firebase from App Server

For example, you can send notif using http POST like this:


Content-Type: application/json
Authorization: Bearer {your access token}

    "token" : "{FCM Token from your device}",
    "notification" : {
      "body" : "This is an FCM notification message!",
      "title" : "FCM (Firebase Cloud Messaging) Message",

Generate private key file:

  1. Go to project settings
  2. Tab “Service Accounts”
  3. Firebase admin SDK
  4. Click generate new private key button
  5. Then use this file to get the bearer access token 🙂

In this case i’m use Java to get bearer access token:

public static String getAccessToken() throws IOException{
        GoogleCredential googleCredential = GoogleCredential
                        new FileInputStream("src/main/resources/app-dcf62-firebase-adminsdk-9ixpm-649284f5fa.json")
                        Arrays.asList("", "")
        return googleCredential.getAccessToken();

Don’t forget to import google api client library to make your life more better :


And to get firebase token from device you can follow me here (next tutorial) if you develop android or IOS using flutter framework.

Note: Before try this, you must setup your android / IOS first to be able retrieve the notification from app server.

Leave a Reply

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