Is there an example on how to send a message from service worker when chrome.alarms event triggers

I have a service worker / background script that has the chrome.alarms.create() code followed by chrome.alarms.onAlarm event handler. Now, when the alarm triggers, I would like to notify my content script. I did see the ports API, but it seems like it first needs to get a message from the content script before it can send a message itself? Also, since I need to declare the event handler in the global scope and not within the ports api handler, how do I go about implementing this?
1 Reply
callmekatootie
callmekatootieOP•16mo ago
Also - should I use the ports api at all? Seems like it establishes a long connection - I only need to prod the content script every minute so not looking for a long term connection
Want results from more Discord servers?
Add your server