Fcm - Programmatically Send Push Notification to User Segments

FCM - Programmatically Send Push Notification To User Segments

Unfortunately, it seems that sending to user segments programatically still isn't possible. Reference here:

But you won't be able to

  1. send notifications to a Firebase User Identifier (UID) and

  2. send notifications to user segments (targeting properties & events like you can on the user console).

It's only possible via the Firebase Console.

Firebase Notification - send to user segment vs send to topic difference

Use User segements

  • To typically send push notifications to a specific and limited set of devices.
  • Message delivery is almost instantaneous (in my experience). Also, I haven't observed throttling as was the case earlier with GCM.

Use Topics

  • Topic or publish/subscribe mechanism is used for a comparatively larger audience and the information type is public. Examples are weather and news.
  • Topics have latency (Message delivery may be throttled)

Send Firebase Cloud Messaging notification to users by user property

There is currently no parameter that you could use to specify a user property (or even for user segments) that will serve as a target for the FCM API to send the message to.

As you've already searched, the only targets possible are single/multiple registration tokens (to and registration_ids), topics, conditions, and device groups (notification_key).

The option you're looking for is currently only available when using the Notifications Console.

Firebase Messaging FCM Distribution over configurable time interval

There is nothing built in that I know of to cause some pseudo-random distribution of delivery. But here are some options I can think of:

  1. From the Firebase console you can schedule the message to be delivered in the user's timezone. If you have a global audience, this means the delivery of the messages will be spread out globally.
  2. Through the API you can delivery a data-only message with the information. This message type is not automatically displayed by the system, but always delivered by your application code. your code can then hold the message and display it after a random delay.

FCM (Firebase Cloud Messaging) Send to multiple devices

Update: For v1, it seems that registration_ids is no longer supported. It is strongly suggested that topics be used instead. Only the parameters shown in the documentation are supported for v1.


Simply use the registration_ids parameter instead of to in your payload. Depending also on your use case, you may use either Topic Messaging or Device Group Messaging.

Topic Messaging

Firebase Cloud Messaging (FCM) topic messaging allows you to send a message to multiple devices that have opted in to a particular topic. Based on the publish/subscribe model, topic messaging supports unlimited subscriptions for each app. You compose topic messages as needed, and Firebase handles message routing and delivering the message reliably to the right devices.

For example, users of a local weather forecasting app could opt in to a "severe weather alerts" topic and receive notifications of storms threatening specified areas. Users of a sports app could subscribe to automatic updates in live game scores for their favorite teams. Developers can choose any topic name that matches the regular expression: "/topics/[a-zA-Z0-9-_.~%]+".



Device Group Messaging

With device group messaging, app servers can send a single message to multiple instances of an app running on devices belonging to a group. Typically, "group" refers a set of different devices that belong to a single user. All devices in a group share a common notification key, which is the token that FCM uses to fan out messages to all devices in the group.

Device group messaging makes it possible for every app instance in a group to reflect the latest messaging state. In addition to sending messages downstream to a notification key, you can enable devices to send upstream messages to a device group. You can use device group messaging with either the XMPP or HTTP connection server. The limit on data payload is 2KB when sending to iOS devices, and 4KB for other platforms.

The maximum number of members allowed for a notification_key is 20.


For more details, you can check out the Sending to Multiple Devices in FCM docs.



Related Topics



Leave a reply



Submit