我正在将数据从Ionic 3中的后台地理位置发送到服务器,因为我为此使用了REST API,但在我的情况下,API并未将数据发送到服务器。
这是我的代码:
this.userData = this.navParams.get('data');
let clientId = this.userData.clientId;
let role = this.userData.role;
const config: BackgroundGeolocationConfig = {
desiredAccuracy: 10,
stationaryRadius: 20,
distanceFilter: 1,
debug: true, // enable this hear sounds for background-geolocation life-cycle.
stopOnTerminate: false, // enable this to clear background location settings when the app terminates
notificationTitle: 'Nearby people check',
notificationText: 'Share your location',
interval: 500,
};
this.backgroundGeolocation.configure(config)
.subscribe((location) => {
let longitude = location.longitude;
let latitude = location.latitude;
this.apiProvider.location(clientId, role, longitude, latitude).then(data=>{
let apiData: any;
apiData = data
alert(apiData.code);
});
});
this.backgroundGeolocation.start();
我想向服务器发送经度和纬度。