[push-api] Moving "PushManager push" onto ServiceWorkerRegistration

Currently serviceworker-dependent APIs are sitting in navigator.whatever,
but now we're adding a ServiceWorkerRegistration object (
https://github.com/slightlyoff/ServiceWorker/issues/365#issue-37477775) it
feels like they should live there.

So instead of:

navigator.serviceWorker.ready.then(function() {
  navigator.push.register(...)
});

it'd be:

navigator.serviceWorker.ready.then(function(reg) {
  reg.push.register(...)
});

This should make it clearer that push registrations are dependent on the
serviceworker registration. Meaning each serviceworker can have its own
push registration, and unregistering a serviceworker means the push is
unregistered with it.

We're also discussing introducing
navigator.serviceWorker.getRegistration(docURL), allowing developers to get
any serviceworker registration on the origin. This means a page like
"/config/" could register/unregister push for other parts of the origins
("/calendar/", "/messaging/" etc).

Does that sound reasonable?

Received on Friday, 11 July 2014 15:17:40 UTC