background geolocation ionic 3 not updating

Looking at examples e.g dnchia/Ionic3-Background-Geolocation you would configure the interval on the background, as well as the periodic foreground send

gps.ts

startTracking(interval) {

    console.log('started tracking')
    const config: BackgroundGeolocationConfig = {
      desiredAccuracy: 10,
      stationaryRadius: 20,
      distanceFilter: 30,
      debug: false, //  enable this hear sounds for background-geolocation life-cycle.
      stopOnTerminate: false,
      interval: interval
    };

app.component.ts

interval = 30000;

constructor() {
  this.sendGPSStart()
  this.interval()
}

sendGPSStart(){
  this.locationTracker.startTracking(this.interval);
}

sendGPSStop(){
  this.locationTracker.stopTracking();
}

interval() {
  setInterval(() => {
    this.locationTracker.sendGPS();
  }, this.interval)

}

Leave a Comment