Unable to get Firebase messaging token in Chrome extension

I am building a chrome extension that receives push notifications. This has worked with previous versions of firebase (4.4.0), but following the recent upgrade to 5.2.0 I am no longer able to get the token. Note that I cleared some caches and made a few additional changes during this upgrade, so it may have nothing to do with the new FB version.

As you can see from the code and output below, when I execute the getToken() promise, it never invokes the “then” or “catch” handlers. I don’t see any messages in the console, network tab, or anything else that indicate anything is happening at all. Any ideas?

  • Chrome Version 67.0.3396.99 (Official Build) (64-bit)
  • MAC 10.12.6

Code in my extension’s background.js:

var config = {
    apiKey: "...",
    authDomain: "...",
    databaseURL: "...",
    projectId: "...",
    storageBucket: "",
    messagingSenderId: "..."
};

firebase.initializeApp(config);
var fbmessaging = firebase.messaging();

function getToken(){

    trace('Getting new token');
    var promise = fbmessaging.getToken();

    trace('Have getToken() promise.  Executing.');
    promise.then(function(newToken) {
        trace('New token received: ' +newToken);
    })
    .catch(function(err) {
        trace('Unable to retrieve refreshed token ', err);
    });
}

fbmessaging.requestPermission()
.then(function() {
    trace('Notification permission granted.');
    getToken();
}).catch(function(err) {
    trace('Unable to get firebase messaging permission: ' +err);
});

fbmessaging.onTokenRefresh(function(arg) {
    trace("OnTokenRefresh called. " +arg);
    getToken();
});

Complete output from trace:

Notification permission granted.
Getting new token
Have getToken() promise.  Executing.

How do I listen for Firebase Cloud Messaging messages in the background in a Google Chrome Extension?

I have a Google Chrome Extension that listens for GCM messages in a background script via chrome.gcm.onMessage.addListener. Our provider is planning to upgrade their infrastructure to use the latest Firebase Cloud Messaging which is no longer compatible with GCM. We’ve confirmed the gcm addListener API no longer receives messages after upgrading to FCM in the dev environment.

I’ve found migration guides for Android, iOS, and progressive web apps but none specifically for background scripts in Chrome extensions.

Some resources I’ve found:

Unrecognized manifest key ‘gcm_sender_id’ ,Chrome extension linked to fcm

am trying to link a chrome extension to firebase cloud messaging, but am getting
Unrecognized manifest key ‘gcm_sender_id’ error when i load the extension
image of the error,
here is my manifest file:

   {

  "manifest_version": 2,
  "name": "iQU",
  "description": "iQU",
  "version": "1.0",
  "browser_action": {
    "default_icon": "icon.png",
    "default_popup": "index.html"
  },
  "permissions": [],
  "content_security_policy": "script-src 'self' 'unsafe-eval' https://cdn.firebase.com https://*.firebaseio.com https://*.firebaseio.com; object-src 'self'; ",
  "web_accessible_resources": [
    "assets/css/*",
    "assets/js/*",
    "assets/fonts/*"
  ],
  "gcm_sender_id": "103953800507"
}

any help please?

Send and receive messages from firebase database through chrome extension

I followed this setup to authenticate my extension with firebase.
https://github.com/firebase/quickstart-js/tree/master/auth/chromextension

I want to push data and receive messages from the firebase db. I registered on the gcm client app. Not sure how to proceed next.

Best way to send push notifications from the server to a chrome extension?

I’m making a chrome extension for a classified ads website. With the chrome extension users will be able to get latest lists from their watched categories/search query.

I am already working on a websocket server to send notifications to users, but this way I have to always have a socket connection open to every user.

My second approach was to use Firebase, but this will run the notification only when a user clicks the icon (as I’ve read), and I would rather have this done from my server

__

Are there any other possible solutions to send notifications to a chrome extension without the user clicking on the icon?