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

Cannot getting location every time in iOS

Open muslimmuda15 opened this issue 1 year ago • 5 comments

Sometimes, my app want to getting current location to user but not every time is successful.

Geolocation.getCurrentPosition(
      ({ coords: { latitude, longitude, accuracy } }) => {
        setUserLoc({
          ...userloc,
          latitude,
          longitude,
          accuracy,
        });

        Geolocation.watchPosition(
          ({ coords: { latitude, longitude, accuracy } }) => {
            setUserLoc({
              ...userloc,
              latitude,
              longitude,
              accuracy,
            });
          },
          error => {
            console.log('watch user position: ', error);
            sendToSlack(
              'Error Watching Location on _getCurrentPosition App.js',
              error,
            );
          },
          {
            enableHighAccuracy: true,
            timeout: 20000,
            maximumAge: 5000,
            distanceFilter: 10,
          },
        );
        setTimeout(() => Geolocation.clearWatch(), 300000);
      },
      error => {
        console.log('error accessing location: ', error);
      },
      { enableHighAccuracy: true, timeout: 20000, maximumAge: 5000 },
    );

I think it will be success in first time only. another time it will be error like this:

{
    "code": 3,
    "message": "Unable to fetch location within 20.0s.",
    "PERMISSION_DENIED": 1,
    "POSITION_UNAVAILABLE": 2,
    "TIMEOUT": 3
}

I have set NSLocationAlwaysUsageDescription and NSLocationAlwaysAndWhenInUseUsageDescription in my info.plist Please help

muslimmuda15 avatar Jul 11 '24 04:07 muslimmuda15

Im having the same issue i have to close and reopen the app completely for it to work again

atlasagencyca avatar Jul 12 '24 22:07 atlasagencyca

++

gulsher7 avatar Jul 18 '24 09:07 gulsher7

++

CostasCF avatar Jul 28 '24 21:07 CostasCF

same here .... but for me 8/10 fails now :( getCurrentPosition never retrieves with data however the permission is granted

petertoth-dev avatar Aug 28 '24 20:08 petertoth-dev

@michalchudziak pls investigate this ASAP, this is extremely frustrating and we are blocked to release our app just because of this... this was the official plugin right?

petertoth-dev avatar Aug 29 '24 00:08 petertoth-dev

Thanks for reporting this problem. It should be solved in 3.4.0 release.

michalchudziak avatar Sep 01 '24 08:09 michalchudziak