Search code examples
javascriptandroidreact-nativegeolocationfrontend

Geolocation not working in React native project


I create a project using expo:

expo init geotest

Next install lib:

npm install react-native-geolocation-service

Add permission in app.json:

"android": {
    "permissions": [
        "ACCESS_FINE_LOCATION"
    ]
}

App.js contains the following code:

https://github.com/Agontuk/react-native-geolocation-service/blob/master/example/App.js

But when I call Geolocation.getCurrentPosition, I get a warning:

[Unhandled promise rejection: TypeError: null is not an object (evaluating 'RNFusedLocation.getCurrentPosition')]

All ideas are over, please help.


Solution

  • I think you should use the expo-location and read the documentation properly. here is link https://docs.expo.io/versions/latest/sdk/location/ . if you are facing any issue by implementing this. then feel free to ask me. thank you.