Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can Chrome extension background script communicate with web page service worker?

Our webapp registers a service worker. We also have a Chrome extension. What we need is to send messages from service worker to the extension without having the webapp open. What is the right approach to do that?

Our current solution is requesting some URL in the service worker and capturing it in the extension's background script using webRequest - chrome.webRequest.onBeforeRequest.addListener. It works but it looks pretty much nonstandardly.

like image 643
Martin Ždila Avatar asked Sep 23 '16 14:09

Martin Ždila


1 Answers

(from wOxxOm's comment, since he hates answering anywhere but in comments)

Your solution is as good as any - before more straightforward support is added, as per this feature request.

like image 140
Xan Avatar answered Sep 20 '22 20:09

Xan