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

[FCM] "getToken" returns invalid token after resetting browser permissions

Open k-1ee opened this issue 1 year ago • 1 comments

Operating System

MacOS Sonoma 14.3

Browser Version

Chrome/Version 121.0.6167.139

Firebase SDK Version

10.7.2

Firebase SDK Product:

Messaging

Describe your project's tooling

Next.js 13.4.12

Describe the problem

After granting browser notification permissions, the call to "getToken" returns an invalid token. Push messages are not being received by the Messaging instance using this token. It seems that an additional call to "getToken" will detect the invalid token and return a new one (which is valid at this point).

Ideally, after granting permissions, the call to "getToken" should not return an invalid token.

Steps and code to reproduce issue

  1. Initialize Firebase, call "getToken" on page load
  2. Grant permission to notify (if necessary, reset browser permissions)
  3. Check retrieved token value in IndexedDB
  4. Reload page, see that "getToken" call has returned a new token

k-1ee avatar Feb 02 '24 01:02 k-1ee

FYI, I suspect there may be a race condition involved with this issue since the issue occurs intermittently.

k-1ee avatar Feb 02 '24 23:02 k-1ee

Any update on this issue ?

gkatrakazas avatar Feb 23 '24 11:02 gkatrakazas

No longer noticing this issue on v10.8.0

k-1ee avatar May 07 '24 22:05 k-1ee