From 284da09f4546356b37511a589fb5f64a3efffe79 Mon Sep 17 00:00:00 2001 From: Manuel <5673677+mtrezza@users.noreply.github.com> Date: Mon, 1 Jul 2024 21:37:29 +0200 Subject: [PATCH 1/2] fix: Invalid push notification tokens are not cleaned up from database for FCM API v2 (#9173) --- src/StatusHandler.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/StatusHandler.js b/src/StatusHandler.js index 7aecf74d..fecfb268 100644 --- a/src/StatusHandler.js +++ b/src/StatusHandler.js @@ -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); } From 6bdd87c21af37f6b9ec7e1aece80322b915d75d6 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 1 Jul 2024 19:38:23 +0000 Subject: [PATCH 2/2] chore(release): 7.1.0-alpha.13 [skip ci] # [7.1.0-alpha.13](https://github.com/parse-community/parse-server/compare/7.1.0-alpha.12...7.1.0-alpha.13) (2024-07-01) ### Bug Fixes * Invalid push notification tokens are not cleaned up from database for FCM API v2 ([#9173](https://github.com/parse-community/parse-server/issues/9173)) ([284da09](https://github.com/parse-community/parse-server/commit/284da09f4546356b37511a589fb5f64a3efffe79)) --- changelogs/CHANGELOG_alpha.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/changelogs/CHANGELOG_alpha.md b/changelogs/CHANGELOG_alpha.md index c5373087..070fa5e1 100644 --- a/changelogs/CHANGELOG_alpha.md +++ b/changelogs/CHANGELOG_alpha.md @@ -1,3 +1,10 @@ +# [7.1.0-alpha.13](https://github.com/parse-community/parse-server/compare/7.1.0-alpha.12...7.1.0-alpha.13) (2024-07-01) + + +### Bug Fixes + +* Invalid push notification tokens are not cleaned up from database for FCM API v2 ([#9173](https://github.com/parse-community/parse-server/issues/9173)) ([284da09](https://github.com/parse-community/parse-server/commit/284da09f4546356b37511a589fb5f64a3efffe79)) + # [7.1.0-alpha.12](https://github.com/parse-community/parse-server/compare/7.1.0-alpha.11...7.1.0-alpha.12) (2024-06-30) diff --git a/package-lock.json b/package-lock.json index 14ad0919..3091a970 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "parse-server", - "version": "7.1.0-beta.1", + "version": "7.1.0-alpha.13", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "parse-server", - "version": "7.1.0-beta.1", + "version": "7.1.0-alpha.13", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { diff --git a/package.json b/package.json index 8f411cb0..a3cd013e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "parse-server", - "version": "7.1.0-beta.1", + "version": "7.1.0-alpha.13", "description": "An express module providing a Parse-compatible API server", "main": "lib/index.js", "repository": {