Send FCM notifications to all user with POSTMAN

You can do it like this, First you have to subscribe to a topic from your devices like below,

    FirebaseMessaging.getInstance().subscribeToTopic("all")
                .addOnCompleteListener { task ->
                    if (task.isSuccessful) {
                        //Successfully Subscribed to Notification Service
                    }else{
                    //Subscription  Notification Service failed
                    }
                }

Then you can send the FCM message to all subscribed devices like this,
Don’t forget to add follwing headers to postman,
Authorization: key=your_firebase_key
Content-Type: application:json

{
  "to": "/topics/all",
  "priority": "high",
  "notification": {
    "title": "Emergency Alert!",
    "body": "body"
  },
    "data" : {
      "your_custom_data" : "data",
    }
}

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top