transistorsoft / nativescript-background-geolocation-lt

Sophisticated, battery-conscious, cross-platform background-geolocation with motion-detection and geofencing
MIT License
73 stars 24 forks source link

getCurrentPosition ignores maximumAge and returns stale locations #113

Open rayneram opened 6 years ago

rayneram commented 6 years ago

Environment

Context

Plugin running in low-power mode (desiredAccuracy=1000) but occasionally needing to return an accurate, current position for the device. getCurrentPosition is being used to do this.

Expected Behavior

By providing a config of {timeout:60, maximumAge:5000, desiredAccuracy:100, samples:100} to getCurrentPosition, the method should return and persist a single location that is no older than 5 seconds and has an accuracy equal or better to 100m.

Actual Behavior

getCurrentPosition returns the first location that satisfied the desiredAccuracy parameter irrespective of maximumAge. This means it frequently returns the stale location which is provided initially by Location Manager and does not continue to wait for a more current one.

Debug logs

Attached log demonstrates this behaviour with a test app that calls getCurrentPosition every two minutes. On each occasion, the API returns an old location rather than waiting for Location Manager to provide a current one.

NSGL-Log1.txt

christocracy commented 6 years ago

Try latest version 1.9.0-beta.2. Note this is a significant refactor. You might want to review the README.

christocracy commented 6 years ago

1.9.0-beta.3 released now. Be sure to do this.