Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49526

Location data not sent to server after I kill the app

$
0
0

I’m building a delivery application. I need to track driver location every X seconds when the app minimized it’s working fine but if I kill the app it’s not sending data to the server. below is my code.

startBackgroundGeolocation() {
const config: BackgroundGeolocationConfig = {
  desiredAccuracy: 1,
  stationaryRadius: 1,
  distanceFilter: 1,
  interval: 10000,
  startOnBoot: true,
  startForeground: true,
  notificationTitle: "Delivery App",
  notificationText: "Test notification text",
  debug: true, //  enable this hear sounds for background-geolocation life-cycle.
  stopOnTerminate: false // enable this to clear background location settings when the app terminates
};

this.backgroundGeolocation.configure(config).then(() => {
  this.backgroundGeolocation
    .on(BackgroundGeolocationEvents.location)
    .subscribe((location: BackgroundGeolocationResponse) => {
      console.log(location);
      console.log('Application Lat' + location.latitude);
      console.log('Application Lon' + location.longitude);

      this.geo.Latitude = location.latitude;
      this.geo.Longitude = location.longitude;
      console.log('API Geo Latitude' + this.geo.Latitude);
      console.log('API Geo Longitude' + this.geo.Longitude);

      //     alert(location.accuracy);

      this.sendGPS();
    });
});

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 49526

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>