w3c / push-api

Push API
https://w3c.github.io/push-api/
Other
144 stars 40 forks source link

Expose pushManager on Navigator #368

Open marcoscaceres opened 7 months ago

marcoscaceres commented 7 months ago

Part of https://github.com/w3c/push-api/issues/360

This PR introduces:

Discussion (or stuff I'm not super happy with):

The current spec is currently hand-wavy about how push registrations are persistently associated with a service worker (which is ok), but not it gets a little bit messier because we need to distinguish between the Window object associated registration and the service worker ones.

Anyone got any suggestions as to what I could use to hand the registration off instead?

The following tasks have been completed:

Implementation commitment:


Preview | Diff

marcoscaceres commented 7 months ago

Actually, thinking about this... if an (main thread) origin (i.e., "a site") has a persistent environment settings object, and service worker has its own independently persistent environment-settings object, then we could say that every environment has an associated push subscription (which can be null).

This could work because:

Tying subscription to the environment then that could answer how push subscriptions are associated with execution contexts.

martinthomson commented 7 months ago

Thanks for writing this up Marcos. I'm going to probably step aside on this one and defer to @saschanaz. Both of us are about to go on some leave, so I hope you don't mind if this takes a little while.

marcoscaceres commented 7 months ago

No problem at all. I'll put up a few PRs over xmas and try to keep them small.

I talked to Anne about using "environment", but he suggested they are too volatile... so, I'm going to create some kind of persistent "push subscriptions store" instead. That will be just simple store that handles the association between push subscriptions, service workers, and the origin.

saschanaz commented 6 months ago

Some early thought:

I talked to Anne about using "environment", but he suggested they are too volatile... so, I'm going to create some kind of persistent "push subscriptions store" instead. That will be just simple store that handles the association between push subscriptions, service workers, and the origin.

Perhaps we can associate push manager to storage bottle as Web Locks does for lock managers?: https://w3c.github.io/web-locks/#lock-managers