Skip to content

[Documentation] Does getToken consistently return the same token across all tabs (browser session)? #8639

@andynewman10

Description

@andynewman10

Operating System

All

Environment (if applicable)

Chrome

Firebase SDK Version

All

Firebase SDK Product(s)

Messaging

Project Tooling

Plain JavaScript

Detailed Problem Description

I am submitting this issue as a bug related to the documentation because it believe it is important.

On the web, when obtaining an FCM token through the API (getToken), it is unclear, by reading the documentation, if the returned token is guaranteed to be the same for all tabs running the same page, on the same domain. Opening multiple tabs on the same page is a common scenario and nothing in the documentation states whether or not the same token will be returned. The behavior of the code will drastically need to be adapted if different token might be returned.

Note that I am not talking about the fact that the same token may be returned at a later time, eg. if the user closes its browser and then reopens it later.

Steps and code to reproduce issue

  • create a JavaScript web page with Firebase set up and that just gets an FCM token
  • open the same page in a second tab and repeat the process. Compare the returned token IDs. Are they guaranteed to be equal? My understanding is that they are, assuming of course no token refresh event took place before the token was requested the second time. Rationale: all tabs share a single (unique) instance of the service worker, which itself has a token bound to it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions