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