firebase-js-sdk icon indicating copy to clipboard operation
firebase-js-sdk copied to clipboard

FR: Support serviceWorkerRegistration option for deleteToken

Open HillBryan opened this issue 1 month ago • 1 comments

Operating System

Windows 11

Environment (if applicable)

Chrome 142.0.7444.163

Firebase SDK Version

12.5.0

Firebase SDK Product(s)

Messaging

Project Tooling

Vue web app / PWA

Detailed Problem Description

This may not be the correct category for this request, but I wanted to open a discussion in the correct place before filing a PR. I implemented a small change to improve the usage of deleteToken(), but while preparing a pull request, I saw the notice that public API changes are currently not being accepted. The notice recommended opening an issue instead, so here it is.

When using FCM with a custom service worker, deleteToken() can only be called reliably in the same session where getToken() was invoked. If getToken() is called, and then after a page reload or later session deleteToken() is called, the operation fails. The behavior is described in detail here and noted as a feature request:
https://github.com/firebase/firebase-js-sdk/issues/8621

The above issue provides workaround, and it does work, but it is not very discoverable, and it’s easy for developers using custom service workers to run into this issue. Especially since older versions of the SDK exposed messaging.useServiceWorker(...), which made the dependency more clear. Today, only getToken() accepts a serviceWorkerRegistration, so it’s not obvious that deleteToken() implicitly depends on the same registration context.

To explore a potential improvement, I created a small change that adds an optional serviceWorkerRegistration parameter to deleteToken(), mirroring the existing pattern in getToken(). This change is backwards compatable as the new options are optional. I have a local PR in my fork if needed for reference:
https://github.com/HillBryan/firebase-js-sdk/pull/2

Is there an estimated timeline for when changes to the public APIs will be open for review?

Thank you!

Steps and code to reproduce issue

Same as description

HillBryan avatar Nov 17 '25 05:11 HillBryan

Giving this issue a gentle nudge. I see that the MR template was changed; thank you!

May I request an internal review for this change? I'm happy to open a MR (https://github.com/HillBryan/firebase-js-sdk/pull/2) with the proposed implementation.

I’ll hold off, of course, if the FCM team doesn’t feel this feature is a good fit.

Thank you!

HillBryan avatar Nov 26 '25 04:11 HillBryan