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

蹲街弑〆低调 提交于 2019-11-30 04:56:40

问题


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.


回答1:


(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.



来源:https://stackoverflow.com/questions/39663229/how-can-chrome-extension-background-script-communicate-with-web-page-service-wor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!