SDK Version: 41
Platforms: all
Hey everybody,
I’m using expo-server-sdk-node
to send push notifications.
I know that if I send multiple push messages each with one recipient token, I’ll get a response with a single status object for each of them in order they were sent (as has been brought up in this thread).
So for example if I send these push messages to the Expo Notifications API:
[
{
"to": "ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]",
"body": "Hello world!"
},
{
"to": "ExponentPushToken[yyyyyyyyyyyyyyyyyyyyyy]",
"body": "You've got mail"
}
]
I can potentially get a response like this if the token in the second message is bad:
{
"data": [
{
"status": "ok",
"id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
},
{
"status": "error",
"id": "YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY",
"message": "The recipient device is not registered with FCM.",
"details": {
"error": "DeviceNotRegistered",
"fault": "developer"
}
}
]
}
That’s fine and I can tell that I should stop sending notifications to the ExponentPushToken[yyyyyyyyyyyyyyyyyyyyyy]
push token.
Now if I send a push message addressed to multiple push tokens, I’ll still get a single status object in response.
E.g. when I send these messages:
[
{
"to": "ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]",
"body": "Hello world!"
},
{
"to": [
"ExponentPushToken[yyyyyyyyyyyyyyyyyyyyyy]",
"ExponentPushToken[zzzzzzzzzzzzzzzzzzzzzz]",
"ExponentPushToken[aaaaaaaaaaaaaaaaaaaaaa]"
],
"body": "You've got mail"
}
]
I can still get a response like this if just one of the three tokens in the second message is bad:
{
"data": [
{
"status": "ok",
"id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
},
{
"status": "error",
"id": "YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY",
"message": "The recipient device is not registered with FCM.",
"details": {
"error": "DeviceNotRegistered",
"fault": "developer"
}
}
]
}
My question is, how can I tell, in this case, which tokens in the second message are bad? Should I just stop addressing push messages to multiple tokens and always send them one-by-one?
Thanks a lot and keep up the good work!