javascript - 地理位置在 React 本机项目中不起作用
问题描述
我使用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')]
所有想法都结束了,请帮助。
解决方案
我认为您应该expo-location
正确使用并阅读文档。这是链接https://docs.expo.io/versions/latest/sdk/location/。如果您在实施此操作时遇到任何问题。然后随时问我。谢谢你。
推荐阅读
- r - 将 r-base 从 v3.6 升级到 v4.0 Linux
- unit-testing - 如何对 ConflatedBroadcastChannel 进行单元测试?
- java - Google 人员是否支持 Java 中的“使用应用操作将 Android 应用扩展为 Google 助理”?
- github - Github API 创建问题 Markdown 不呈现
- matlab - 在 Matlab 中的某个背景上绘制一个实心黑色圆圈
- python - 试图删除包含某些字符的目录
- npm - “NPM -i”(本地)可以在我不知道的情况下安装全局包吗?
- azure-devops - 使用部署槽部署 Azure Functions 时如何避免主机重启?
- flutter - 根据颤动中的变量更改背景颜色
- c# - 使用 puppeteersharp 返回 Image base 64 而不将文件保存在硬盘中