Skip to content

v9 api has no equivalent to GetToken in firebase/messaging/sw & is therefore impossible to use in Chrome Extension #5169

@samdoeswork

Description

@samdoeswork

[REQUIRED] Describe your environment

  • Operating System version: Windows10
  • Browser version: Chrome latest
  • Firebase SDK version: 9.0.0-beta.6
  • Firebase Product: Messaging

[REQUIRED] Describe the problem

Steps to reproduce:

I am trying to use FCM to trigger onBackgroundMessage in a Chrome extension.

I found the API reference has methods specific to Service Workers (https://firebase.google.com/docs/reference/js/v9/messaging_sw) & was able to successfully call getMessaging in a chrome extension with manifest v3.

However there is no getToken() equivalent method - so it's not possible to target individuals.

In general I've spent hours trying to setup v9 api with Chrome Extensions manifest v3 and there is absolutely no documentation on this topic.

Relevant Code:

Here is my best effort. I cannot get onBackgroundMessage to actually trigger in any Chrome Extension scenario (manifest v3) & additionally cannot access tokens.

import { getMessaging, onBackgroundMessage} from "firebase/messaging/sw";
async initFCM() {
    const firebaseApp = initializeApp({ ... });
    const fcm = getMessaging(firebaseApp);
    onBackgroundMessage(this.fcm, (payload) => {
      console.log("Received background message ", payload); // never triggers
    });
  }

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions