Broadcast push notification to multiple recipients

Is the only way to broadcast same message to multiple recipients to send multiple messages like this:
[{
“to”: “ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]”,
“sound”: “default”,
“body”: “Hello world!”
}, {
“to”: “ExponentPushToken[yyyyyyyyyyyyyyyyyyyyyy]”,
“sound”: “default”,
“body”: “Hello world!”
}]?

Or is there a way to send one message that will contain multiple push tokens? E.g. something like this:
{
“to”: [“ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]”, “ExponentPushToken[yyyyyyyyyyyyyyyyyyyyyy]”],
“sound”: “default”,
“body”: “Hello world!”
}

I think
{
“to”: [“ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]”, “ExponentPushToken[yyyyyyyyyyyyyyyyyyyyyy]”],
“sound”: “default”,
“body”: “Hello world!”
}

would be way cooler. But they don’t support it yet I guess

Hey @ilebedie and @gopidon! Thanks for checking out Expo, here is the official answer:

The HTTP request body must be JSON. It may either be a single message object or an array of up to 100 messages. We recommend using an array when you want to send multiple messages to efficiently minimize the number of requests you need to make to Expo servers. This is an example request body that sends two messages:

So you can use this example to send the same message, and represent that message with a javascript variable.

[{
  "to": "ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]",
  "sound": "default",
  "body": "Hello world!"
}, {
  "to": "ExponentPushToken[yyyyyyyyyyyyyyyyyyyyyy]",
  "badge": 1,
  "body": "You've got mail"
}]

For more details, visit here: https://docs.expo.io/versions/latest/guides/push-notifications.html

Let me know if you have any questions!

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.