Closed sainjay closed 1 month ago
Just checked, doesn't seem to be happening in iOS. Updated my libraries to use the latest version of both the libaries:
"react-native-background-fetch": "^4.2.5", "react-native-background-geolocation": "^4.17.1",
The problem is your desiredAccuracy: 1
provided to .getCurrentPosition
.
The options.desiredAccuracy
for .getCurrentPosition
doesn't have the same meaning as that supplied to .ready(config)
. When you provide desiredAccuracy: 1
to .getCurrentPosition
, you're saying "I desire a location with a minimum accuracy of 1 meter". (NOTE .getCurrentPosition
always turns on location-services to request the highest possible accuracy).
Of course, a location with accuracy: 1
is impossible since the best accuracy you'll ever get is 5 meters
. The plugin looks at its last-known-location and says "That last location cannot satisfy your desiredAccuracy: 1
-- I will turn on location-services to fetch a new location and return the best possible".
Solution: increase your options.desiredAccuracy
(eg: 100).
yes, working as expected after increasing the desiredAccuracy
to 150 and initial config accuracy is 100. Thanks!
While using the
getCurrentPosition
method and settingmaximumAge
in the config, the location is not getting the last fetched location and always getting a new location.Your Environment
react-native -v
): bunx expo-env-infolet startTime = performance.now(); const location = await BackgroundGeolocation.getCurrentPosition({ ...appLocationConfig, }); let endTime = performance.now();