Max
PD🧩 Plasmo Developers
•Created by Max on 2/6/2025 in #👾extension
Subscribing to web push
I was able to resolve this by subscribing to the pushmanager in response to the
activate
event:
Note that I used self.addEventListener
rather than this.addEventListener
like many chrome extension sources recommend. this
isn't available in plasmo, but pallas noted that self
works.
Also, using ExtendableEvent.waitUntil
is critical: it blocks until the promise it's passed resolves, ensuring the subscription is created before the service worker exits.
It would be helpful if some documentation about this sort of thing somewhere, both about responding to events (this vs self) in BSWs, and about how to handle async setup stuff like the pushmanager. I was barely able to piece together docs between chrome's spotty references on extensions and plasmo's sparse docs3 replies