Tokens are getting status DeviceNotRegistered without any reason

I have two apps under the same user. Both working with sdk with version 25.0.0.
We have started getting DeviceNotRegistered responses for push notifications for random users. It will work for a user for some time, and then we will get this status, and then the token will not work (as said in the docs). The user will have to reinstall the app.
We are sending notifications from a firebase function using the expo-server-sdk with version 2.3.3.
We were basing on expo and accessing the app through its url.
We tried building a standalone for android for both of the apps, however still the token can become invalid (event after just a few notifications).
It is very inconsistent - sometimes it will become invalid immediately, sometimes after a day.

What could be the reason for this issue?

Thanks for the help!

The code for sending notifications:

const Expo = require('expo-server-sdk');
let expo = new Expo();
let sendNotifications = (notifications) => {
    let chunks = expo.chunkPushNotifications(notifications);

    let promises = [];

    for (let chunk of chunks) {
        promises.push(new Promise((resolve, reject) => {
            expo.sendPushNotificationsAsync(chunk)
                .then(receipts => {
                    console.log("Successfully sent notifications : \n", receipts);
                    resolve(receipts);
                })
                .catch(err => {
                    console.error("Failed to send notifications : \n", err);
                    reject(err);
                });
        }));
    }
    return Promise.all(promises);
};
1 Like

I also have this problem, but on the devices I tested the first time I install the APP, the token is invalid, the second time I install the APP on the same Device, the token is valid.

Hi! Sorry about this issue. We’ve been working hard on a fix but it unfortunately required a lot of changes on our end. We just put up a guide on using FCM for push notifications which should fix the problem: https://docs.expo.io/versions/latest/guides/using-fcm. Please let us know if you run into problems with the new system and sorry for the trouble.

Hi @jesse ,
I did not understand couple of things in the guide.

  1. It will only work with stand alone android builds? It says it will not work with android expo client, and will not work on ios at all? If a token belongs to an ios device will it get a notification?
  2. Basically the code stays the same - I still send notifications to the expo endpoint (or using exponent-server-sdk-node for example), and the difference is that expo will use my firebase project instead of expo’s. Will this have an affect on the DeviceNotRegistered problem?

Thanks!

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