我正在使用 Ionic4
开发必须在前台和后台模式下获取用户移动位置的软件。
- 我使用了 ionic 4 后台模式来使应用程序在后台运行。
- 使用地理位置来获取移动位置。
这geolocation.getCurrentPosition
在前台运行良好,但在后台运行良好。但是当我们再次恢复应用程序时它会返回值。
我已经尝试了很多方法来解决这个问题,但它仍然给出了相同的结果。谁能帮我解决这个问题?提前致谢。
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();
});