Когда я убиваю приложение, фоновые службы не работают в приложении Ionic Cordova - PullRequest
0 голосов
/ 03 октября 2019

Когда я закрываю приложение, фоновые службы не работают в приложении Ionic Cordova.

Я использую этот плагин: @ mauron85 / cordova-plugin-background-geolocation.

Среда:

Ionic-4, Cordova-8, Android Устройство: Redmi note 5 pro, ОС Android: Oreo

Это мой код.

let config: BackgroundGeolocationConfig = {
  desiredAccuracy: 10,
  stationaryRadius: 0,
  distanceFilter: 0,
  notificationTitle: 'Background Tracking',
  notificationText: 'Enabled',
  debug: true,
  interval: 10000,
  stopOnTerminate: false,
  startOnBoot: true,
  url: '  http://192.168.43.182:8000/geolocation',
  httpHeaders: {
    'Content-Type': 'application/json'
  },

  postTemplate: {
    latitude: this.latitude,
    longitude: this.longitude,
    deviceId : '8234832',
    userId: 'eeehimanshu22@gmail.com'
  }

};

this.backgroundGeolocation.configure(config).then(() => {
  this.backgroundGeolocation.on(BackgroundGeolocationEvents.location).subscribe((location: BackgroundGeolocationResponse) => {
    console.log("loc: "+location)
    this.zone.run(() => {
      this.latitude = location.latitude;
      this.longitude = location.longitude;
    })
  })
})

this.backgroundGeolocation.start();

Как я могуисправить это?

...