Re: [w3c/ServiceWorker] Expose GeoLocation to workers (#745)

Plan B
====

Separate "Background Location" permission required. Total isolation/mutual exclusion between Client location gathering and Service Worker's efforts: -

// https://example.com/serviceworker.js
this.ontravel = function(event) {
  console.log(event.position);
  // From here we can postMessage() the position details to client, 
  // we can foreground the client, or we can merely XHR/Fetch the details
  // to the fleet-management server so that everyone can see where their pizza is.
}

// https://example.com/webapp.js
navigator.serviceWorker.register('serviceworker.js').then(
  function(serviceWorkerRegistration) {
  // This next line is when the user gets prompted for background geolocation access permission
    serviceWorkerRegistration.travelManager.subscribe({accurate:true, minJourney:10}).then(
      function(pushSubscription) {
        console.log(pushSubscription.options);
      }, function(error) {
        // During development it often helps to log errors to the
        // console. In a production environment it might make sense to
        // also report information about errors back to the
        // application server.
        console.log(error);
      }
    );
  });

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/745#issuecomment-306392712

Received on Tuesday, 6 June 2017 06:18:21 UTC