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

572 views Asked by At

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:

1

There are 1 answers

0
Jameal G On

The extension that I mentioned in my question three years ago still exists today and continues to rely on the chrome.gcm extension API.

Recently we noticed the gcm.notification.badge value is no longer being passed along with the data object, instead we're seeing a gcm.notification.e property that I believe contains the badge value. I was unable to find any documentation on why that property changed but I did find an answer to my original question:

We are deprecating the chrome.gcm API and encourage you to move to Web Push Notifications using VAPID authentication. This works on the Web, in Chrome Extensions and in Chrome Apps. You can find more information here:

https://developers.google.com/web/fundamentals/push-notifications/

Web Push Notifications offer a slightly different set of features from the chrome.gcm API. Please file an issue or contact us directly if you believe that it cannot satisfy your requirements.

Source: https://bugs.chromium.org/p/chromium/issues/detail?id=831532