react-native-geolocation icon indicating copy to clipboard operation
react-native-geolocation copied to clipboard

`auto` always yields the Android location provider, not Play Services

Open jkaufman opened this issue 2 years ago • 3 comments

Reviewing the code, it appears that the default location provider configuration setting, auto, always yields the Android location provider.

  • At GeolocationModule.java:37, mLocationManager is set to AndroidLocationManager.
  • When the configuration is set, onConfigurationChange checks for the values android and playServices, but auto is a no-op. As a consequence, the location manager remains android by default.

On line 54:

else if (Objects.equals(config.locationProvider, "playServices") && mLocationManager instanceof AndroidLocationManager)

… should probably read …

else if ((Objects.equals(config.locationProvider, "playServices") || Objects.equals(config.locationProvider, "auto")) && mLocationManager instanceof AndroidLocationManager)

jkaufman avatar Jul 27 '23 16:07 jkaufman

Hey, that's correct. I indeed wanted to keep the android.location backend default for 3.X release, to get the feedback from the community and resolve issues. I will change this behaviour in upcoming versions when it becomes stable enough.

michalchudziak avatar Aug 29 '23 17:08 michalchudziak

That is super interesting @jkaufman ! Thanks for sharing this.

This part of the docs does not seem to reflect this behavior:

locationProvider (string, Android-only) - Either "playServices", "android", or "auto". Determines wether to use Google’s Location Services API or Android’s Location API. The "auto" mode defaults to android, and falls back to Android's Location API if play services aren't available.

Many developers might be mislead and thinking they use the new play API but they are not, which leads to many issues about poor accuracy

christophemenager avatar Jul 04 '24 06:07 christophemenager