Reputation: 3995
I'm building a 3rd party push notification solution to be integrated into a number of properties. Some of those properties are using other 3rd party services with service workers that listen for push events. So I now have two service workers registered to listen to the same event, and that causes mayhem.
I've read up on service worker scopes, but that doesn't seem to address my problem. I don't see a way to limit push notifications to a scope.
Am I just not understanding something?
Upvotes: 1
Views: 1122
Reputation: 8660
No. Two Service Workers are not able to share a scope.
You can think of Service Workers as Highlanders. There can be only one.
You can register as many as you want, but the last registration will always override the others.
Per the Spec:
2.2. Service Worker Registration A service worker registration is a tuple of a scope url and a set of service workers, an installing worker, a waiting worker, and an active worker. A user agent may enable many service worker registrations at a single origin so long as the scope url of the service worker registration differs. A service worker registration of an identical scope url when one already exists in the user agent causes the existing service worker registration to be replaced.
Upvotes: 2