function onDeviceReady() {
navigator.geolocation.watchPosition(onSuccess, onError);
var callbackFn = function(location) {
console.log('[js] BackgroundGeolocation callback: ' + location.latitude + ',' + location.longitude);
当应用程序关闭时,此获取代码不会发送位置。我也尝试了其他方法,但没有成功将位置数据发送到服务器。
$.get('http://test.com/rotech/location.php?latitude=' + location.latitude);
backgroundGeolocation.finish();
};
var failureFn = function(error) {
console.log('BackgroundGeolocation error');
};
backgroundGeolocation.configure(callbackFn, failureFn, {
desiredAccuracy: 10,
stationaryRadius: 20,
distanceFilter: 30,
interval: 60000
});
backgroundGeolocation.start();
}