Enable enableHighAccuracy in iOS only returns position after timeout
See original GitHub issueWith build 5.0 and enableHighAccuracy=true
the position on iOS devices is only returned after the timeout is reached. Im my case this is after 10 seconds. When I disable enableHighAccuracy it works fine. This is a new behaviour with build 5. Before it worked as expected.
This only happens on real devices. In the simulator it immediately returns the location.
I am using the following options for getCurrentPosition:
{
distanceFilter: 100,
enableHighAccuracy: true,
timeout: 10000,
maximumAge: 60 * 5 * 1000
}
I tested this on several iOS devices and the behaviour is the same.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:13
- Comments:31 (12 by maintainers)
Top Results From Across the Web
Timeout about geolocation always reached when position ...
I use the below workaround to get GPS-only working. As low-accuracy is faster, the timeout is 4s. $cordovaGeolocation.getCurrentPosition({enableHighAccuracy: ...
Read more >Geolocation.getCurrentPosition() - Web APIs | MDN
The default value is Infinity , meaning that getCurrentPosition() won't return until the position is available. enableHighAccuracy.
Read more >cordova-plugin-geolocation
Returned when the device is unable to retrieve a position within the time specified by the timeout included in geolocationOptions . When used...
Read more >react-native-geolocation-service Code Examples - Snyk
On Apple we can not detect when/if a * location permission has been granted or denied. For that reason after a * predefined...
Read more >react-native-geolocation-service - npm
React native geolocation service for iOS and android. ... NOTE: Location request can still timeout since many android devices have GPS issue ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Went through
requestLocation
iOS docs which this library uses forgetCurrentPosition
. According to them, this function will try to get GPS data for the accuracy set. Under the hood enableHighAccuracy useskCLLocationAccuracyBest
which is the highest accuracy possible. GPS algorithms use lot of data to calculate GPS position like wifi, bluetooth, mobile signal and GPS. Hence calculating GPS location with accuracykCLLocationAccuracyBest
will vary from place to place.According to the docs it will return GPS location if it satisfies the desired accuracy or after timeout. Hence for your error cases it looks like the device is taking around 10 sec to get the desired accuracy, so this delay.
Earlier this library used to start a GPS continuous update request and will stop on first result and send the response in
getCurrentPosition
. This should have returned first location earlier, but this might not be of required accuracy. This is how continuous GPS location request works.So, you have two options to solve this problem,
enableHighAccuracy:false
(which will use like city level accuracy).There are other accuracy options in iOS native API, but that is not supported in this library.
kCLLocationAccuracyReduced
is supported only in iOS 14. For iOS < 14, should we fall back to usethreeKilometers
?