chrome extension with service worker receiving pus

2019-06-25 10:35发布

问题:

I've successfully built a service worker that receives push notifications following this tutorial.

And I was trying to build a chrome extension that would allow me to subcripe to the push notifications. But it seems that when the extension runs the service worker is not supported.

Service Worker Error :^( DOMException: Failed to register a ServiceWorker: The URL protocol of the current origin ('chrome-extension://dghajjpcbhcpnnkkgehjhhceemhcacoc') is not supported.

Am I missing some permissions on the manifest.js?

I followed this tutorial for the Chrome extension.

回答1:

Enabling Service Workers for Chrome extensions is still a work in progress. You can track it here. It seems that it is already available in the Canary and Dev channels.

You don't need a Service Worker to be able to receive push notifications in a Chrome extension. You can use the chrome.gcm API.