title: How can I run watchposition on background using service worker Angular 6
body: <p>I'm using Angular 6 PWA , I want to check the position of the user when he enters or leaves a particular area. "geoFencing";</p>
  
  <p>It's works when the user is on my app, but what I want is to execute it in the background even when the browser is closed.</p>
  
  <p>Code for the geofencing </p>
  
  <pre><code>var id, target, options;
  
  function success(pos) {
    var crd = pos.coords;
  
    if (target.latitude === crd.latitude &amp;&amp; target.longitude === crd.longitude) {
      console.log('Congratulations, you reached the target');
      navigator.geolocation.clearWatch(id);
    }
  }
  
  function error(err) {
    console.warn('ERROR(' + err.code + '): ' + err.message);
  }
  
  target = {
    latitude : 0,
    longitude: 0
  };
  
  options = {
    enableHighAccuracy: false,
    timeout: 5000,
    maximumAge: 0
  };
  
  id = navigator.geolocation.watchPosition(success, error, options);
  </code></pre>