Ionic2 使用ionic 3中的后台地理位置将位置数据更新到服务器不起作用

Ionic2 使用ionic 3中的后台地理位置将位置数据更新到服务器不起作用,ionic2,geolocation,ionic3,cordova-plugins,Ionic2,Geolocation,Ionic3,Cordova Plugins,我正在使用。它在前台提供位置详细信息,并在应用程序关闭时提供调试消息,但不会将位置详细信息更新到前台和后台服务器中 提前谢谢 const config: BackgroundGeolocationConfig = { desiredAccuracy: 10, stationaryRadius: 10, distanceFilter: 10, debug: false, stopOnTerminate: false, startForeground:

我正在使用。它在前台提供位置详细信息,并在应用程序关闭时提供调试消息,但不会将位置详细信息更新到前台和后台服务器中

提前谢谢

const config: BackgroundGeolocationConfig = {
    desiredAccuracy: 10,
    stationaryRadius: 10,
    distanceFilter: 10,
    debug: false,
    stopOnTerminate: false,
    startForeground: true,
    notificationTitle: 'location tracking',
    notificationText: 'Active',
    interval: 60000,

    url: localStorage.getItem('api_base_url')+'user/currentlocation',
    syncUrl:localStorage.getItem('api_base_url')+'user/currentlocation',
    httpHeaders: {
      'Content-Type': 'application/json'
    },
    postTemplate: {
      lat: '@latitude',
      lon: '@longitude',
      user_id: '1',
      currentDate: '12-12-2019',
      address: 'test',
    }
    };

this.backgroundGeolocation.configure(config)
  .then(() => {

    this.backgroundGeolocation.on(BackgroundGeolocationEvents.location).subscribe((location: BackgroundGeolocationResponse) => {
      console.log(location);
    });

  });

this.backgroundGeolocation.start();

请记住,当postTemplate为jsonObject且为jsonArray的数组时,所有位置(即使是单个位置)都将作为对象数组发送

在服务器端,我将JSON对象更改为对象数组

比如说,

{
  "user_id": "1",
  "lon": "13.2",
  "lat": "82.3"
}
我将上面的JSON对象更改为

[{
  "user_id": "1",
  "lon": "13.2",
  "lat": "82.3"
}]