Ionic framework 当我关闭应用程序时,Ionic Cordova应用程序中的后台服务不起作用
当我关闭应用程序时,Ionic Cordova应用程序中的后台服务不起作用 我正在使用这个插件:@mauron85/cordova插件背景地理位置 环境: 爱奥尼亚-4,科尔多瓦-8,安卓设备:Redmi note 5 pro,安卓操作系统:Oreo 这是我的密码Ionic framework 当我关闭应用程序时,Ionic Cordova应用程序中的后台服务不起作用,ionic-framework,cordova-plugins,phonegap-plugins,ionic4,ionic-native,Ionic Framework,Cordova Plugins,Phonegap Plugins,Ionic4,Ionic Native,当我关闭应用程序时,Ionic Cordova应用程序中的后台服务不起作用 我正在使用这个插件:@mauron85/cordova插件背景地理位置 环境: 爱奥尼亚-4,科尔多瓦-8,安卓设备:Redmi note 5 pro,安卓操作系统:Oreo 这是我的密码 let config: BackgroundGeolocationConfig = { desiredAccuracy: 10, stationaryRadius: 0, distanceFilter: 0, noti
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();
如何修复此问题?插件按预期工作,后台模式表示应用程序仍处于活动状态,但位于另一个选项卡中,而不是当前活动的应用程序。当你退出应用程序时,无法继续跟踪我知道的地理位置。谢谢你的评论。即使应用程序被禁用,我也会获取后台地理位置数据,但无法在后台模式下发布到Http服务器。在通知区,我可以看到后台正在运行。