Skip to content

feat(messaging): migrate FCM Web quickstart to FID-based APIs - #1080

Open
hozhng wants to merge 1 commit into
firebase:masterfrom
hozhng:feat/fcm-fid-api-migration
Open

feat(messaging): migrate FCM Web quickstart to FID-based APIs#1080
hozhng wants to merge 1 commit into
firebase:masterfrom
hozhng:feat/fcm-fid-api-migration

Conversation

@hozhng

@hozhng hozhng commented Aug 18, 2026

Copy link
Copy Markdown

Description

Migrate Firebase Cloud Messaging (FCM) Web quickstart sample app to use the new FID-based SDK APIs.

Key Changes

  • API Migration: Replaced deprecated getToken / deleteToken with register / unregister and onRegistered / onUnregistered callbacks in messaging/main.ts.
  • UI & Terminology: Updated UI text and DOM elements from "Registration Token" to "Installation ID (FID)".
  • Permission & Non-user-gesture Handling: Added proper permission state checks on initial page load to avoid browser permission prompt suppressions.
  • Dependency Upgrade: Bumped firebase to ^12.17.1.
  • Documentation: Updated README.md to reflect FID registration flow and FCM HTTP v1 cURL format.

Verification

  • Tested locally with Vite (npm run dev).
  • Verified permission granting, onRegistered callback receiving FID, Foreground onMessage handler, and unregister flow.
  • Verified TypeScript build passes (npm run build).

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Firebase Cloud Messaging (FCM) Quickstart sample to use the latest Firebase SDK (v12.17.1) and transitions the implementation from legacy registration tokens to the new FID-based (Firebase Installation ID) APIs. Key changes include updating the main application and service worker scripts, revising the HTML UI to display the FID, and updating the README with the FCM HTTP v1 API documentation. The review feedback highlights several critical issues: a version mismatch between the service worker and the main application, potential runtime crashes in environments lacking the Notification API, a UI bug where denied permission errors are hidden, and a typo in the HTML charset attribute.

Comment thread messaging/firebase-messaging-sw.js Outdated
Comment thread messaging/main.ts
Comment thread messaging/main.ts Outdated
Comment thread messaging/index.html Outdated
@hozhng
hozhng force-pushed the feat/fcm-fid-api-migration branch 7 times, most recently from 9bfe127 to f439ad6 Compare August 18, 2026 19:42
@hozhng
hozhng marked this pull request as draft August 18, 2026 20:51
@hozhng
hozhng marked this pull request as ready for review August 18, 2026 20:53
Comment thread messaging/README.md Outdated
Comment thread messaging/README.md
Comment thread messaging/README.md
Comment thread messaging/README.md
Comment thread messaging/firebase-messaging-sw.js
Comment thread messaging/index.html
Comment thread messaging/index.html Outdated
Comment thread messaging/main.ts
Comment thread messaging/main.ts Outdated
Comment thread messaging/main.ts
@hozhng
hozhng force-pushed the feat/fcm-fid-api-migration branch 3 times, most recently from 14de063 to f7f3feb Compare August 25, 2026 17:57

@Doris-Ge Doris-Ge left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you deploy your latest changes in this PR to https://android-gcm-test-519bd.web.app/?

Comment thread messaging/README.md Outdated
Comment thread messaging/README.md Outdated
Comment thread messaging/README.md Outdated
Comment thread messaging/README.md Outdated
Comment thread messaging/README.md Outdated
Comment thread messaging/main.ts Outdated
@hozhng
hozhng force-pushed the feat/fcm-fid-api-migration branch from f7f3feb to 3f12cd8 Compare September 1, 2026 22:18
@hozhng

hozhng commented Sep 1, 2026

Copy link
Copy Markdown
Author

Could you deploy your latest changes in this PR to https://android-gcm-test-519bd.web.app/?

done!

@hozhng
hozhng requested a review from Doris-Ge September 2, 2026 21:05
@hozhng hozhng self-assigned this Sep 2, 2026
@hozhng
hozhng force-pushed the feat/fcm-fid-api-migration branch from 3f12cd8 to 3da73f4 Compare September 2, 2026 21:25
Comment thread messaging/index.html Outdated
Comment thread messaging/main.ts Outdated
Comment on lines +127 to +130
// TODO(developer): Retrieve a registration token for use with FCM.
// In many cases once an app has been granted notification permission,
// it should update its UI reflecting this.
// Retrieve registration FID for use with FCM.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// TODO(developer): Retrieve a registration token for use with FCM.
// In many cases once an app has been granted notification permission,
// it should update its UI reflecting this.
// Retrieve registration FID for use with FCM.
// TODO(developer): Retrieve Firebase Installation ID (FID) for use with FCM.
// In many cases once an app has been granted notification permission,
// it should update its UI reflecting this.

Comment thread messaging/main.ts Outdated
console.log('Error retrieving registration token. ', err);
showToken('Error retrieving registration token.');
function unregisterFromFirebase() {
// Unregister registration FID.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Unregister registration FID.
// Unregister FID with FCM.

Comment thread messaging/main.ts Outdated
Comment thread messaging/main.ts
@hozhng
hozhng force-pushed the feat/fcm-fid-api-migration branch from d8a8240 to fe7371d Compare September 3, 2026 17:29
- Replace deprecated getToken/deleteToken with register/unregister and onRegistered/onUnregistered callbacks
- Update UI elements and terminology from Registration Token to Installation ID (FID)
- Upgrade firebase dependency to ^12.17.1 to support FID APIs
- Update README documentation and cURL instructions for FCM HTTP v1 API

Bug: b/522441204
@hozhng
hozhng force-pushed the feat/fcm-fid-api-migration branch from fe7371d to 3d210d0 Compare September 3, 2026 17:40
@hozhng
hozhng requested a review from Doris-Ge September 3, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants