Hello guys,
I installed and configured background geolocation plugin (
https://github.com/mauron85/cordova-plugin-background-geolocation ) with no problems.
let config: BackgroundGeolocationConfig = {
desiredAccuracy: 10,
stationaryRadius: 1,
distanceFilter: 1,
debug: true,
interval: 2000,
stopOnTerminate: false,
url: 'my-link',
postTemplate: {
lat: '@latitude',
lng: '@longitude'
};
this.backgroundGeolocation.configure(config).then((location: BackgroundGeolocationResponse)=>{
this.globals.lat = location.latitude;
this.globals.lng = location.longitude;
this.storage.set('lat',location.latitude);
this.storage.set('lng',location.longitude);
}, (error) => {
alert(error);
});
this.backgroundGeolocation.start();
The coords are saved to server every time the location changes, even if my app is completely closed. The problem is that when there is not internet connection i want to save locations to a local sqlite table and when internet connection returns send this table to server, and I dont know the function-listener of plugin where i have to put my “write to sqlite table” code. The function
BackgroundGeolocation.on('location', function(location) {...});
causes build error with the message that expected 1 argument. Could anyone help me???