Hello All,
I’m using cordova-plugin-mauron85-background-geolocation for fetching the location in the background even when the app is not running in the foreground. What I want to achieve is to get the coordinates of the user and send it or post it to the server for real-time location tracking and updating the DB.
I think the problem is location points are updating in the background but the data is not posted to the server.
Is there any way to interact with the server when the app is not in the foreground.
This is my code:
// Background Tracking
let config: BackgroundGeolocationConfig = {
desiredAccuracy: 0,
stationaryRadius: 20,
distanceFilter: 10,
debug: true,
interval: 2000
};
this.backgroundGeolocation
.configure(config)
.subscribe((location: BackgroundGeolocationResponse) => {
console.log('BackgroundGeolocation: ' + location.latitude + ',' + location.longitude);
// Run update inside of Angular's zone
this.zone.run(() => {
this.lat = location.latitude;
this.lng = location.longitude;
});
// Server interaction to POST location coordinates.
}, (err) => {
console.log("ERROR in config", err);
});
Any help will be highly appreciated.
Thanks