I have read and tested a lot of issues but I still can not get geolocation on Android.
I use navigator.geolocation.getCurrentPosition, on iOS everything works fine, but on Android I have no answer to this function, either success or error.
I have installed react-native-permissions to make sure that the user has activated the permissions but it does not change anything because it says that everything is "authorized".
I noticed that it came from GPS of the device. If I activate it manually, everyting works fine. However, I can not find a way to activate it for the user. On iOS, if GPS is not activated, I fall in the error callback and tell user to activate it, but on android, nothing is happennig.
I don't understand why I can't get geolocation only with getCurrentPosition (I have ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION in manifest).
Here a part of my code:
componentDidMount() {navigator.geolocation.getCurrentPosition( (position) => { //do my stuff with position value }, (error) => { Permissions.getPermissionStatus('location') .then((response) => { if (response !== "authorized") { Alert.alert("Error","We need to access to your location", [ { text: "Cancel", onPress: () => { // do my stuff }, style: 'cancel' }, { text: "Open Settings", onPress: () => Permissions.openSettings() } ] ); } else { // do my stuff } }); }, { enableHighAccuracy: true, timeout: 2000, maximumAge: 1000 });}
Does anyone have any idea ?
Thank you