geolocation - BackgroundGeolocation 不在后台工作,但在前台火灾中为什么?
问题描述
团队我已经在我们的应用程序中实现了跟踪功能并使用了 BackgroundGeolocation,但它在我们提到的场景下面无法在后台工作:
情况1:
如果我是前台而不是后台,则 BackgroundGeolocation 仅触发 1 次,下面我们用于 BackgroundGeolocation 的链接:
https://www.joshmorony.com/adding-background-geolocation-to-an-ionic-2-application/
我已经尝试了上面的链接,但我得到了相同的结果。我真的在 ionic3 中遇到了位置问题,而且任何查询都不支持 ionic 社区。
loadLocation(){
// foreground Tracking
var self = this;
//get user currentLocation and update user location after move move
self.watch = this.geolocation.watchPosition(options).filter((p: any) => p.code === undefined).subscribe((position: Geoposition) => {
//self.subscription = self.watch.subscribe((position) => {
var latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
console.log('lat fire1.....', +position.coords.latitude);
console.log('long fire.....', +position.coords.longitude);
//set center to map and set zoom....
self.map.setCenter(latLng);
self.map.setZoom(16);
//updateDriverLocation for get driver updated location...
self.updateDriverLocation(position.coords.latitude, position.coords.longitude);
//moveMarker for ,move marker......
self.moveMarker(position);
}, (err) => {
console.log(err);
});
// Background Tracking
let config = {
desiredAccuracy: 0,
stationaryRadius: 20,
distanceFilter: 10,
debug: true,
interval: 2000
};
this.backgroundGeolocation.configure(config).subscribe((location) => {
alert('dddddd');
console.log('BackgroundGeolocation: ' + location.latitude + ',' + location.longitude);
//updateDriverLocation for get driver updated location...
self.updateDriverLocation(location.latitude,location.longitude);
self.moveMarker(location);
}, (err) => {
console.log(err);
});
// Turn ON the background-geolocation system.
this.backgroundGeolocation.start();
}
我尝试了所有方法,但没有任何效果,请团队帮助我。
解决方案
推荐阅读
- python - 将数据从一个数据帧复制到另一个数据帧
- go - 如何在 sarama 中获得多个订阅
- powershell - 使用 PowerShell 解析字符串
- angular - 模板中 Observable 集合的 Observable
- javascript - 当您真正想要创建副作用时,“函数式编程”背后的哲学是什么?
- django - 部署 django 应用程序时出现内部服务器错误
- arrays - Swift 的 String.count 的 BigO 是什么?
- javascript - href 不会转到上层 div id
- vba - filename.csv 的文件格式和扩展名不匹配
- vba - VBA遍历工作簿中的工作表