简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM