5

I'm trying to build a chrome extension that updates its badge every time some event happens on my server- in this case, my server is receiving a webhook from Zoom and then informing my chrome extension that the event occurred. From there my chrome extension will update a counter on its' badge, to show that the event occured. I'm trying to build it according to the chrome extension Manifest V3 but I can't find any info on how to do this correctly.

To my understanding, in Manifest V3 all client-side scripts must run in a service worker. That service worker starts up, runs some code, and then shuts down again. I was planning to open a websocket in my background script, which would have been fine under manifest v2, but I don't think you can do that any more.

My question is: How do I maintain a connection to receive data in my chrome extension? When I say data in this case I really just mean an event informing my chrome extension to update the counter on its badge.

Are there other routes besides keeping a websocket open in the background? I've looked around at things like Google Cloud Messaging but I don't think that was intended for what I would like to use it for.

  • 2
    Use `Push` API which will wake the worker. Alternatively, [force the worker to be alive](https://stackoverflow.com/questions/66618136/persistent-service-worker-in-chrome-extension/66618269) – wOxxOm Aug 28 '21 at 17:40
  • @wOxxOm Thank you! I actually started doing this at one point but I thought it might not be the correct way to use Push API since most of the examples I've seen for its use are for push notifications. – Ben Bilhorn Aug 28 '21 at 18:05

0 Answers0