Push Notification Receipt Errors: How to handle them correctly?

  1. SDK Version: 37
  2. 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?

Did you every figure this out? I’m really curious too.

Yes I did. The documentation mentations in a short sentence that the received tickets are in the same order as the sent expo-push tokens. so you can create a token to ticket map or something similar and store that in your database.

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