离子3背景地理位置在背景中停止

时间:2018-04-30 10:36:06

标签: background geolocation ionic3

我正在使用插件 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();

0 个答案:

没有答案