react-native-location-tracking icon indicating copy to clipboard operation
react-native-location-tracking copied to clipboard

navigator.geolocation.watchPosition not working

Open ravi-pandit14 opened this issue 6 years ago • 5 comments

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});
   }

ravi-pandit14 avatar Jan 08 '20 05:01 ravi-pandit14

You are facing this issue on Android or iOS?

vikrantnegi avatar Jan 08 '20 06:01 vikrantnegi

@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",

ravi-pandit14 avatar Jan 09 '20 04:01 ravi-pandit14

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.

vikrantnegi avatar Jan 09 '20 04:01 vikrantnegi

Please help I am also facing same issue which is undefined is not an object (evaluating 'navigator.geolocation.watchPosition') .

Richesoft avatar Dec 29 '20 07:12 Richesoft

Please use react-native-geolocation-service navigator API.

vikrantnegi avatar Dec 29 '20 08:12 vikrantnegi