Same Notification to multiple devices

#1

I was wondering, if it is possible, to send the same notification to multiple devices owned by the same person.
If my user logs in on an tablet but also its mobile phone, I want to send the notifications to both.

Right now it looks like the only way I see is by sending the same content to as multiple messages as for example described here:

[{
  "to": "ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]", // user 1 phone
  "sound": "default",
  "body": "Hello world!"
}, {
  "to": "ExponentPushToken[yyyyyyyyyyyyyyyyyyyyyy]", // user 1 tablet
  "sound": "default",
  "body": "Hello world!"
}]

Is there some other way to do this nicer, for example with multiple tokens in the to field?

#2

I think this is the only way to do it. Perhaps the best strategy would be to make a function that takes in all ids you want to send and makes the list of identical messages.

2 Likes