Implement register() and FID-based registration with onRegistered / onUnregistered#9714
Merged
zwu52 merged 7 commits intofeat/messaging-api-seriesfrom Mar 24, 2026
Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
…llback (draft) Made-with: Cursor
- Restore copyright year to 2020; add JSDoc for FID-dedupe behavior - Serialize get FID + compare + notify to avoid duplicate callback on concurrent register() - Add lastNotifiedFid assertion and three-call FID-change test Made-with: Cursor
182879a to
39f546b
Compare
OrlandriaH-G
approved these changes
Mar 11, 2026
Doris-Ge
reviewed
Mar 16, 2026
Doris-Ge
reviewed
Mar 17, 2026
DellaBitta
reviewed
Mar 19, 2026
Doris-Ge
reviewed
Mar 20, 2026
…lint Made-with: Cursor
Doris-Ge
approved these changes
Mar 20, 2026
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.
Implements Phase 2 of FCM Web modernization: a new register() API that links the app to its Firebase Installation ID (FID) and delivers it via the onRegistered callback, plus onUnregistered for when a FID is deactivated. This supports moving from legacy FCM tokens to FID as the primary send target.
register(messaging, options?) ensures VAPID and service worker are set, gets the FID from Installations, and invokes onRegistered with it (same options as getToken). When register() is called multiple times, onRegistered is only invoked when the FID changes from the last notified value (or on first call). The “get FID → compare → notify” step is serialized so concurrent register() calls do not trigger duplicate callbacks for the same FID.
New surface: onRegistered(messaging, nextOrObserver) and onUnregistered(messaging, nextOrObserver) for subscribing to FID delivery and deactivation. Unit tests cover options passthrough, observer vs function handler, FID source, and the dedupe and three-call FID-change behavior. All 78 messaging tests pass.