developer
developer

Reputation: 31

sending fcm notification messages to multiple android devices by registration_ids parameter

I want to send notifications to multiple android devices(where same app is installed) by fcm from php server side by calling this url -

https://fcm.googleapis.com/fcm/send

I checked sending messages to device groups but my requirement is such that there will not be definite devices to which i will send messages because i am going to do it in a hourly cron job, and each time a cron job runs it will send notification messages to different different devices according to requirements. or can it be done in another way?

But i am thinking to use "registration_ids" parameter instead of "to" parameter, details of these fields here in the Downstream HTTP messages section. In this registration_ids field i will put all required device registration tokens in array. Now my question is after receiving message in android device can the message be parsed in the android app sdk codes?. i am in a bit of doubt as in this documentation there are no mentions of registration_ids parameter when sending messages to multiple android devices. Please assure me. And furthermore, will the message be sent when android app is in background?!. Please don't write one line, provide some examples if possible.

Upvotes: 0

Views: 1317

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598817

In the documentation for building requests to send to multiple devices you will find an example of passing multiple FCM tokens in a single call to the FCM API in the tokens parameter (in Node.js) or by using a HTTP batch request with multiple subrequests (in the REST API).

If you're having a hard time making this work, posting a question that shows what you tried increases the chances that someone can help making it work.


Yes, the message is sent regardless of whether the app is in the foreground, or in background. Whether the notification is actually shown depends on many more factors, many of which are outside of your control (such as the Android version, device maker/OEM, and the user settings).

Upvotes: 1

Related Questions