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);
};