navigator.geolocation.watchPosition not working
Description I am facing geolocation.watchPosition issue. This not working in your example project. Issue In my case I am using "react-native-geolocation-service" dependency and i have also use "@react-native-community/geolocation" It's does not return position continuously. My code
watchGeolocation = () => {
console.log('watchGeolocation')
this.watchID = Geolocation.watchPosition(position => {
const lastPosition = JSON.stringify(position);
console.log(lastPosition); // only first time display log
setwatch(position.coords.latitude)
},(error) => console.log(JSON.stringify(error)),
{enableHighAccuracy: true,interval:500,useSignificantChanges:true});
}
You are facing this issue on Android or iOS?
@vikrantnegi I am facing this issue on Android
AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
package.json "react": "16.8.6", "react-native": "0.60.5", "react-native-geolocation-service": "^3.1.0", "@react-native-community/geolocation": "^2.0.2",
The issue is not related to the repo itself but the location permission. I believe you might also need to request for permission. You can try using react-native-permission.
I will try to update the repo with the latest react native and add geolocation.
Please help I am also facing same issue which is undefined is not an object (evaluating 'navigator.geolocation.watchPosition') .
Please use react-native-geolocation-service navigator API.