-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Add a way to remove an invalid token if sendFCM returns 404 #32440
base: develop
Are you sure you want to change the base?
Conversation
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #32440 +/- ##
===========================================
+ Coverage 55.81% 55.82% +0.01%
===========================================
Files 2413 2413
Lines 53160 53160
Branches 10925 10925
===========================================
+ Hits 29669 29679 +10
+ Misses 20871 20863 -8
+ Partials 2620 2618 -2
Flags with carried forward coverage won't be shown. Click here to find out more. |
export const sendFCM = function ({ userTokens, notification, _replaceToken, _removeToken, options }: NativeNotificationParameters): void { | ||
// We don't use these parameters, but we need to keep them to keep the function signature | ||
// TODO: Remove them when we remove the old sendGCM function | ||
_replaceToken; | ||
_removeToken; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this means this fix can't be backported if we are taking these out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could, not sure if it is worth it though.
Since these parameters are still being passed to the sendFCM
I am just not destructuring the _replaceTokens
one, since we don't need it here.
I was being dumb in the previous PR, instead of adding this comment I could've just not desctructured them :)
Proposed changes (including videos or screenshots)
The old library (
node-gcm
) we used to send messages via the legacy push had some utilities to help us out implementing the specification described here on how to handle error codes, and we used to functions, _removeToken and _replaceToken to minimize the number of unnecessary errors we would propagate over.Now, we had to implement the utility to send messages manually, in #32208 now, we implemented most of the error handling utilities in the function called
fetchWithRetry
, but there was a big one missing, the 404 case.From the spec:
UNREGISTERED (HTTP error code = 404) App instance was unregistered from FCM. This usually means that the token used is no longer valid and a new one must be used.
This error can be caused by missing registration tokens, or unregistered tokens.
Missing Registration: If the message's target is a token value, check that the request contains a registration token.
Not registered: An existing registration token may cease to be valid in a number of scenarios, including:
For all these cases, remove this registration token from the app server and stop using it to send messages.
OBS: not adding
replaceToken
because the new Firebase API does not return the new device token ever, so it is better to just remove it, and let it be recreated when a new push gets sent.Issue(s)
CONN-205
Steps to test or reproduce
You can just follow: #32208
Further comments