expo: [expo-notifications] DeviceNotRegistered: The recipient device is not registered with FCM.

šŸ› Bug Report

Summary of Issue

token = (await Notifications.getExpoPushTokenAsync({ experienceId: experienceId })).data; retrieves invalid push tokens Here are some:

ExponentPushToken[0J23tlOl6Qz92gG9SM4ceI] ExponentPushToken[qcL4EiLB_aTct8VdVsXFfu] ExponentPushToken[D5PQ0qDWvvDqoomMg8I2G8]

Environment - output of expo diagnostics & the platform(s) you’re targeting

Bare workflow

  Expo CLI 3.22.3 environment info:
    System:
      OS: Windows 10 10.0.18362
    Binaries:
      Node: 14.4.0 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.4 - C:\Users\Myself\AppData\Roaming\npm\yarn.CMD
      npm: 6.14.4 - C:\Program Files\nodejs\npm.CMD
    npmPackages:
      expo: ^38.0.8 => 38.0.8
      react: ~16.11.0 => 16.11.0
      react-dom: ~16.11.0 => 16.11.0
      react-native: ~0.62.2 => 0.62.2
      react-native-web: ~0.11.7 => 0.11.7

Reproducible Demo

https://expo.io/notifications

Steps to Reproduce

retrieved token with token = (await Notifications.getExpoPushTokenAsync({ experienceId: experienceId })).data;

https://exp.host/--/api/v2/push/send
POST
{
    "to": "ExponentPushToken[qcL4EiLB_aTct8VdVsXFfu]",
    "sound": "default",
    "title": "Test",
    "body": "Test",
    "data": { "data": "goes here" }
  }

Expected Behavior vs Actual Behavior

{
    "data": {
        "id": "20ede6dd-95d8-484d-96aa-3560c21031a3",
        "status": "error",
        "message": "The recipient device is not registered with FCM.",
        "details": {
            "error": "DeviceNotRegistered",
            "fault": "developer"
        }
    }
}

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 29 (10 by maintainers)

Most upvoted comments

I’m not really sure what exactly is causing this issue, but we aren’t seeing any abnormalities with FCM notifications from our end. Expo is simply forwarding along this error message from FCM- it’s the Unregistered device error listed here: https://firebase.google.com/docs/cloud-messaging/http-server-ref

This looks like a similar issue to this one, so just double-check your steps match those

I’ve followed all those steps… otherwise it would not work at all… šŸ¤·ā€ā™‚ļø BTW, i’m running these latest tests on LDPLayer. Can that be the problem?

Deleting the app and reinstalling it will generate a new Expo push token

As I’ve stated above, Expo is simply forwarding this error message along from FCM. We’ve had this error message posted a few times, and it’s always been a configuration issue, or the device’s token is no longer valid (app hasn’t been opened in a while or the user revoked notification permissions).

Here’s a great list of common mistakes when setting up FCM notifications in Expo.

Google’s documentation is very clear that if you receive this message, you should stop sending notifications to the app:

An existing registration token may cease to be valid in a number of scenarios, including:

  • If the client app unregisters with FCM.If the client app is automatically unregistered, which can happen if the user uninstalls the application. For example, on iOS, if the APNs Feedback Service reported the APNs token as invalid.
  • If the registration token expires (for example, Google might decide to refresh registration tokens, or the APNs token has expired for iOS devices).
  • If the client app is updated but the new version is not configured to receive messages.

For all these cases, remove this registration token from the app server and stop using it to send messages.

@Ciberusps there’s a section in the expo-notifications module docs guide specifically for this - https://github.com/expo/expo/tree/master/packages/expo-notifications#add-your-projects-credentials-to-expo-server-optional - and it links to that page šŸ˜„