当我杀死该应用程序时,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();
我该如何解决?