Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/StatusHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,23 @@ export function pushStatusHandler(config, existingObjectId) {
) {
const token = result.device.deviceToken;
const error = result.response.error;
// GCM errors
// GCM / FCM HTTP v1 API errors; see:
// https://firebase.google.com/docs/reference/fcm/rest/v1/ErrorCode
if (error === 'NotRegistered' || error === 'InvalidRegistration') {
devicesToRemove.push(token);
}
// APNS errors
// FCM API v2 errors; see:
// https://firebase.google.com/docs/cloud-messaging/manage-tokens
// https://github.com/firebase/functions-samples/blob/703c0359eacf07a551751d1319d34f912a2cd828/Node/fcm-notifications/functions/index.js#L89-L93C16
if (
error?.code === 'messaging/registration-token-not-registered' ||
error?.code === 'messaging/invalid-registration-token' ||
(error?.code === 'messaging/invalid-argument' && error?.message === 'The registration token is not a valid FCM registration token')
) {
devicesToRemove.push(token);
}
// APNS errors; see:
// https://developer.apple.com/documentation/usernotifications/handling-notification-responses-from-apns
if (error === 'Unregistered' || error === 'BadDeviceToken') {
devicesToRemove.push(token);
}
Expand Down