Hello everyone!
My app has a functionality which draws a path in a map when the user walks. It must work in background too, so I installed this plugin: https://ionicframework.com/docs/native/background-geolocation/
It works perfectly in Android and draws the polyline exactly where I walk. But in iOS it presents a strange behaviour. The path is drawn normally, but suddenly something fails and the plugin returns a location “in the past”. I’ll post an example, with a real path around a lake.
Sometimes it “jumps” to a previous point and then returns. I’m receiving a notification: Outstanding bg-task was force-killed, and I suppose this is the cause of the error.
I’m following the steps in the plugin documentation, I call finish() in the end of the subscribed function. I’ll post below part of my code.
// When device ready.
config() {
let config = {
notificationTitle: 'Title...',
notificationText: 'Message...',
desiredAccuracy: 10,
stationaryRadius: 20,
distanceFilter: 10,
debug: true,
interval: 500
};
this.backgroundGeolocation.configure(config).subscribe((location) => {
this.lat = location.latitude;
this.lng = location.longitude;
this.backgroundGeolocation.finish();
}, (err) => {
// I've never seen this alert.
alert(err);
});
}
// When user starts the path.
startBG() {
this.backgroundGeolocation.start();
}
// When user finishes the path.
stopBG() {
this.backgroundGeolocation.stop();
this.backgroundGeolocation.finish();
}
May someone help me with this question?
Thanks in advance!