Фоновая геолокация не работает в ioni c 3 в фоновом режиме - PullRequest
0 голосов
/ 22 апреля 2020

Плагин Cordova background-geolocation не работает, когда приложение находится в фоновом режиме в Ioni c 3. Этот код вызывается в файле app.component.ts. Этот код вызывает этот веб-сервис только на переднем плане, а не в фоновом режиме или на выключенном экране.

 startTracking() {
    // Background Tracking
    let config = {
      desiredAccuracy: 0,
      stationaryRadius: 20,
      distanceFilter: 10, 
      debug: true,
      interval: 2000 
    };
    this.backgroundGeolocation.configure(config).subscribe((location) => {
      console.log('BackgroundGeolocation:  ' + location.latitude + ',' + location.longitude);
      // Run update inside of Angular's zone
      this.zone.run(() => {
        this.geoLatitude = location.latitude;
        this.geoLongitude = location.longitude;
        this.TrackLiveLocation();//for call our private webservice
    });
      });
    }, (err) => {
      console.log(err);
    });
    // Turn ON the background-geolocation system.
    this.backgroundGeolocation.start();
    // Foreground Tracking
  let options = {
    frequency: 3000, 
    enableHighAccuracy: true
  };
  this.watch = this.geolocation.watchPosition(options).filter((p: any) => p.code === undefined).subscribe((position: Geoposition) => {
    console.log(position);
    // Run update inside of Angular's zone
    this.zone.run(() => {
      this.geoLatitude = position.coords.latitude;
      this.geoLongitude = position.coords.longitude;
      this.TrackLiveLocation();//for call our private webservice
    });
  });
  }
...