GCM Deprecation Update (April 17, 2019)

403 views
Skip to first unread message

Simeon Vincent

unread,
Apr 17, 2019, 2:21:16 PM4/17/19
to Chromium Extensions
Hey GCM API users,

A few hours ago crbug.com/831532 was updated with the latest details about the Google Cloud Messaging deprecation. I wanted to call it out here in case folks aren't CCed on that issue. For the sake of saving you a click I'm including the latest description text below.

Simeon - @dotproto
Extensions Developer Advocate

---

The Firebase Cloud Messaging project announced a number of deprecations in 2018 that may affect usage in Chrome. This bug contains additional information on what changes, when, and how to make sure that your websites and extensions continue to work.

🠞 What is changing?
A number of public GCM endpoints will be shut down by May 29—these are the URLs that you use to send messages to subscriptions from your server. Going forward, a Firebase endpoint will have to be used when sending messages.

https://developers.google.com/cloud-messaging/android/android-migrate-fcm#update-server-endpoints

For chrome.gcm, replace the GCM endpoint with the FCM endpoint when sending messages. Subscriptions continue to be valid.

For Web Push:
a) when using the GCM protocol, replace the GCM endpoint with the FCM endpoint when sending messages.
b) when using the Web Push protocol, you should already have FCM endpoints and be unaffected.

Starting with Chrome 74, the old GCM endpoint will not be advertised anymore by Chrome.

🠞 Will the chrome.gcm API stop working in May?
No, the chrome.gcm API will continue to work beyond May as long as you use an FCM endpoint. We do ask you to migrate to chrome.instanceID for creating new registrations.

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.

🠞 What was that about the chrome.gcm.register() function?
The chrome.gcm.register() function uses an older registration format that we plan to discontinue later in 2019. A precise timeline is not yet known, but you can use this as an opportunity to start migrating users away from it.

Instead of using chrome.gcm.register() to create a subscription, you should use chrome.instanceID.getToken(). Instead of chrome.gcm.unregister(), you should use chrome.instanceID.deleteToken(). Messages will continue to be delivered to the chrome.gcm.onMessage event.

OLD CODE:

chrome.gcm.register('123456789', registrationId => {
// Send the |registrationId| to the server.
});

NEW CODE:

chrome.instanceID.getToken({ authorizedEntity: '123456789', scope: 'GCM' }, tokenId => {
// Send the |tokenId| to the server. It can be used everywhere where
// you use the |registrationId| today.
}

Please find more information on the following pages. Again, however, we do encourage you to migrate to Web Push Notifications instead.

https://developer.chrome.com/apps/instanceID
https://developer.chrome.com/apps/gcm

Jason Savard

unread,
Apr 17, 2019, 5:15:22 PM4/17/19
to Chromium Extensions
Thanks for posting this.

I am replying to file an issue because Web Push Notifications will not work for data messages.

My extensions need to process the data messages and not simply display notification messages to the client.

I am currently doing this with chrome.gcm.onMessage, however, with its deprecation what is the alternative?

and in the interim can you confirm chrome.gcm.onMessage will also continue working past May?

Simeon Vincent

unread,
Apr 26, 2019, 5:06:40 AM4/26/19
to Chromium Extensions
I am replying to file an issue because Web Push Notifications will not work for data messages.

Longer term, this is something we may be able to address at the web platform level. This is only an idea at the moment, but I'd like to see Web Push support non-notification messages in extensions and possibly for installed PWAs. For now, FCM is the easiest transition.


I am currently doing this with chrome.gcm.onMessage, however, with its deprecation what is the alternative?
and in the interim can you confirm chrome.gcm.onMessage will also continue working past May?

You will still use chrome.gcm.onMessage to listen for FCM messages, but you'll need to tweak how you create a subscription. See the "What was that about the chrome.gcm.register() function" section for details.


Simeon - @dotproto
Extensions Developer Advocate

Reply all
Reply to author
Forward
0 new messages