Repository navigation
fix(push-notifications): resolve unregister() only after FCM token deletion completes on Android - #2607
Open
ciccilleju wants to merge 1 commit into
Open
fix(push-notifications): resolve unregister() only after FCM token deletion completes on Android#2607ciccilleju wants to merge 1 commit into
ciccilleju wants to merge 1 commit into
Conversation
…letion completes on Android unregister() resolved right after calling deleteToken(), so a register() issued before the deletion finished received the cached token, which FCM invalidated moments later. Resolve from the deleteToken() completion listener and reject if the deletion fails.
Author
|
This also addresses #2593. The issue occurs even when awaiting The CI, Bot, and Release Dev Build for PR workflows currently show |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
On Android,
unregister()callsFirebaseMessaging.deleteToken()and resolves the JavaScript call immediately, before token deletion finishes. Even when the application awaitsunregister()before callingregister(),getToken()can still return the cached token. FCM then invalidates that token, leaving the backend with a token that fails withUNREGISTEREDand preventing subsequent push delivery.This change resolves
unregister()fromdeleteToken()'s completion listener and rejects the call if deletion fails. The change is limited to Android; the iOS implementation is unchanged.Fixes #2593.
Reproduction
registrationevent.registrationevent. With the current implementation, the previous token can be returned while its deletion is still pending; sending to that token subsequently fails withUNREGISTERED.unregister()promise resolves only after deletion succeeds, so the awaitedregister()starts after that deletion has completed. A deletion failure rejectsunregister()instead of reporting success.Validation
patch-packageto@capacitor/push-notifications8.1.3, in an app using Capacitor 8.5.2.action_required.