Geolocation on iOS is slow because it is always using high accuracy
See original GitHub issueThe geolocation plugin on iOS is taking a long time to get the users location because it is always using kCLLocationAccuracyBest
or kCLLocationAccuracyBestForNavigation
. Pull request #1773 added the option for enableHighAccuracy
, but according to Apple’s developer documentation on kCLLocationAccuracyBestForNavigation
: “Because of the extra power requirements, use this level of accuracy only while the device is plugged in.”. This level of accuracy seems like it is too high to be used for enableHighAccuracy
.
The cordova plugin equivalent uses kCLLocationAccuracyThreeKilometers
by default and kCLLocationAccuracyBest
for high accuracy.
Ideally the user could choose the desired accuracy from all of the iOS options listed in the documentation, but these might not line up with android very well. Regardless the current implementation takes a long time to get the current location, especially when high accuracy is not required by the app.
Note that the long wait time to fetch the current location is not as noticeable on the simulator and a physical device should be used to see the true wait time.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:25 (7 by maintainers)
Top GitHub Comments
I just found a workaround that returns the location in less than 50ms on my iOS device, even with
enableHighAccuracy
set to true:What tipped me of was this article that says that using
startUpdatingLocation()
andstopUpdatingLocation()
can be much faster than usingrequestLocation()
I am having the same issue. In my case it didn’t matter if
enableHighAccuracy
was set to true or false, getting the current position on iOS took each time around 10 seconds. On android on the other hand the position is returned almost immediately.