Please provide the following:
- SDK Version: 36.0.2
- Platforms(Android/iOS/web/all): iOS
We’ve started getting Push Notification errors
The recipient device is not registered with FCM., details: error: DeviceNotRegistered, fault: developer, runParams: [Object]
This is consistently happening for iOS devices.
My first concern is how an iOS device is getting Expo Push Token that is referring FCM it should be only applicable for Android right?
However, our app supports both Android and iOS and same user can login on both platforms.
But, we’ve ensured that as soon as user logs in a ExpoToken is fetched from device and not from our own backend.
So the latest device user has logged into, should receive the Push Notfication.
Here is the code:
import { Notifications } from "expo";
runPostLoginTasks()
{
...
processPushTokenForUser();
...
}
static async processPushTokenForUser() {
// This is called after Login so that push token can be refreshed in backend as well as in app.
// Get the token that uniquely identifies this device
let newToken;
try {
newToken = await Notifications.getExpoPushTokenAsync();
} catch (e) {
// Do not throw.
}
log.debug("New Token", newToken);
let existingToken;
try {
existingToken = await LocalDBProxy.findAppData<string>(Constants.EXPO_PUSH_TOKEN);
}
catch (e) {
// DO NOT THROW
}
log.debug("Existing Token", existingToken);
if (newToken && newToken !== existingToken) {
// Store Token against APP-SETTINGs
LocalDBProxy.saveAppData(Constants.EXPO_PUSH_TOKEN, newToken);
}
// POST the token to backend to send push notifications.
if (
newToken &&
GlobalState.isUserLoggedIn &&
GlobalState.user!.expoPushToken !== newToken
) {
BackendAPI.updateAttributes({ expoPushToken: newToken });
GlobalState.user!.expoPushToken = newToken;
}
}
Please help. Our production app is being affected due to this.
Thanks