I am using Ionic4
Developing software that has to fetch the user's mobile location in both foreground and background mode.
- I have used ionic 4 background mode to enable the app to run in background.
- Using geolocation to fetch the mobile location.
This geolocation.getCurrentPosition
is working fine in foreground but not in background. But it returns value when we resume the app again.
I have tried a lot of ways to solve this issue but still it is giving the same. Can anyone help me solve this issue? Thanks in advance.
var options: PositionOptions = { enableHighAccuracy: true };
this.geolocation.getCurrentPosition(options).then(res => {
this.zone.run(() => {
console.log('Get current position Success = ', res);
this.getCurrentPosistion();
// this.updateLocationInDatabase(location.coords);
});
}).catch(err => {
console.error('Error occurred = ', err);
this.getCurrentPosistion();
});