我正在使用插件 https://github.com/mauron85/cordova-plugin-background-geolocation
它工作正常,在前景时,但一旦它进入后台就停止工作。请告诉我如何处理这个问题。
我的LocationProvider构造函数中的代码
const config: BackgroundGeolocationConfig = {
desiredAccuracy: 10,
stationaryRadius: 20,
distanceFilter: 30,
debug: true, // enable this hear sounds for background-geolocation life-cycle.
stopOnTerminate: false, // enable this to clear background location settings when the app terminates
};
this.backgroundGeolocation.configure(config)
.subscribe((location: BackgroundGeolocationResponse) => {
this.zone.run(() => {
console.log(location);
})
});
构造函数之后的函数
startTracking(){
console.log("Starting Tracking");
// start recording location
this.backgroundGeolocation.start();
}
从home.ts构造函数
调用此函数this.location.startTracking();