- SDK Version: 37
- Platforms(Android/iOS/web/all): Android/iOS
When sending Push Notifications you get receipts from the expo server sdk.
Later you can retrieve the status of those receipts and check for errors. If the error is DeviceNotRegistered, the documentation suggests that you remove the corresponding Expo push tokens.
My Question is: How do I know what the correct Expo push token is?
Unfortunately the error message of the ticket is of no help:
{“data”:{“id”:“e3bd4ac4-026d-42fc-be93-709f690f722a”,“status”:“error”,“message”:“The recipient device is not registered with FCM.”,“details”:{“error”:“DeviceNotRegistered”,“fault”:“developer”}}}
This would be an example of how the push notifications are sent:
let message = {
to: pushTokens,
message: 'Hello!',
data: {
userId
}
}
const res = await expo.sendPushNotificationsAsync([message]);
const receiptIds = res.filter(r => r.status === 'ok').map(r => r.id);
const receipts = await expo.getPushNotificationReceiptsAsync(receiptIds);
I would like to store the ticket Ids with the matching receipt Ids in my database. But I am not sure if getPushNotificationReceiptsAsync
responds the tickets in the same order as the pushTokens
array.
Are there any suggestions?