Don't send old FCM tokens when new token is generated during startup #1440
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fix stops the code from pushing the old FCM token to Ring when a new token is generated during registration, for example, due to migration to FCMv1 APIs for registration. The bug happens because the very last command in the push notification initialization sequence currently sends the FCM token to Ring any time
credentials
is defined:The problem with this is
credentials
is assigned prior to registration so it would still hold the old FCM token even if a new token was generated during the registration process. Because of this, the sequence of events was something like this:onCredentialsChanged()
was called which subsequently pushed the new generated FCM token to Ringcrendentials
was previously defined and still contained the old FCM token, the command noted above would also run immediately pushing the old FCM token back to Ring thus making it impossible to receive notifications with the new push registrationThe new code only pushes the stored FCM token if it was unchanged during registration.