地理位置无法在React Native项目中使用

问题描述 投票:0回答:1

我使用expo创建一个项目:

expo init geotest

下一个安装库:

npm install react-native-geolocation-service

在app.json中添加权限:

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

App.js包含以下代码:

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

但是当我调用Geolocation.getCurrentPosition时,会收到警告:

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

所有想法都结束了,请帮忙。

javascript android react-native geolocation frontend
1个回答
0
投票

我认为您应该使用expo-location并正确阅读文档。这是链接https://docs.expo.io/versions/latest/sdk/location/。如果您通过实施此方法遇到任何问题。然后随便问我。谢谢。

© www.soinside.com 2019 - 2024. All rights reserved.