I have an application which sends notification for multiple users at a time(not all user). So how to do this using Firebase Push Notification?
2 Answers
You can use Topic Messaging
Based on the publish/subscribe model, FCM topic messaging allows you to send a message to multiple devices that have opted in to a particular topic.
Topic messaging supports unlimited topics and subscriptions for each app.
To subscribe to a topic, the client app calls Firebase Cloud Messaging subscribeToTopic() with the FCM topic name:
FirebaseMessaging.getInstance().subscribeToTopic("news");
To send a notification on topic :
https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{
"to": "/topics/news",
"data": {
"message": "This is a Firebase Cloud Messaging Topic Message!",
}
}
Read more at here : https://firebase.google.com/docs/cloud-messaging/android/topic-messaging

- 1,898
- 1
- 17
- 23
-
What if only from the server side is possible to know which device should receive a notification? In legacy api it was possible sending to a dynamic group of tokens, and also to create a named group with a key. – Mauro Piccotti Mar 09 '18 at 11:10
To send notification to multiple users, you need to register the users a single topic
example topic called Weather
, then all users registered will get a notification.
To be able to send the push notification, you can use cloud functions:
Cloud Functions for Firebase lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. Your code is stored in Google's cloud and runs in a managed environment. There's no need to manage and scale your own servers.
more info here: https://firebase.google.com/docs/functions/

- 78,874
- 25
- 140
- 134