Search code examples
react-nativegpsexpo

How can I get the current accuracy value in expo-location?


I am developing react-native for the first time and I cannot say that I fully understand the location API. Location API has values ​​from 1 to 6 for accuracy and I want to get the GPS accuracy value instantly and show a warning if the value is less than 4. How can I achieve this?

expo-location version: 13.0.4 Platform: IOS, android


Solution

  • When you call Location.getCurrentPositionAsync(options) the response object contains "accuracy" key which you can use to get value of accuracy.

    Moreover if you need to add check for GPS accuracy it would be better to use Location.enableNetworkProviderAsync(), it asks the user to turn on high accuracy location mode.