File tree 1 file changed +14
-2
lines changed
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -237,11 +237,23 @@ export function pushStatusHandler(config, existingObjectId) {
237
237
) {
238
238
const token = result . device . deviceToken ;
239
239
const error = result . response . error ;
240
- // GCM errors
240
+ // GCM / FCM HTTP v1 API errors; see:
241
+ // https://firebase.google.com/docs/reference/fcm/rest/v1/ErrorCode
241
242
if ( error === 'NotRegistered' || error === 'InvalidRegistration' ) {
242
243
devicesToRemove . push ( token ) ;
243
244
}
244
- // APNS errors
245
+ // FCM API v2 errors; see:
246
+ // https://firebase.google.com/docs/cloud-messaging/manage-tokens
247
+ // https://github.com/firebase/functions-samples/blob/703c0359eacf07a551751d1319d34f912a2cd828/Node/fcm-notifications/functions/index.js#L89-L93C16
248
+ if (
249
+ error ?. code === 'messaging/registration-token-not-registered' ||
250
+ error ?. code === 'messaging/invalid-registration-token' ||
251
+ ( error ?. code === 'messaging/invalid-argument' && error ?. message === 'The registration token is not a valid FCM registration token' )
252
+ ) {
253
+ devicesToRemove . push ( token ) ;
254
+ }
255
+ // APNS errors; see:
256
+ // https://developer.apple.com/documentation/usernotifications/handling-notification-responses-from-apns
245
257
if ( error === 'Unregistered' || error === 'BadDeviceToken' ) {
246
258
devicesToRemove . push ( token ) ;
247
259
}
You can’t perform that action at this time.
0 commit comments