gpt4 book ai didi

ios - React Native 无权限对话

转载 作者:可可西里 更新时间:2023-11-01 06:19:28 24 4
gpt4 key购买 nike

我正在尝试使用 React Native 获取我的用户在 iOS 上的位置。我在 plist 中添加了位置隐私描述,我尝试了各种代码,但没有一个显示对话请求许可。现在,我正在使用这个库:https://github.com/yonahforst/react-native-permissions

我请求位置权限的代码如下:

componentDidMount() {
Permissions.request('location', 'whenInUse')
.then(res => {
console.log(res);
})

这什么都不做。当我检查权限时,它显示未确定

请注意,我的应用确实显示在位置隐私设置中。

最佳答案

使用 react-native 0.48.3 iOS 11.1 遇到同样的问题,解决方案是将所有现有位置权限添加到 Info.plist

<key>NSLocationAlwaysUsageDescription</key>
<string>some string</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>some string</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>some string</string>
<key>NSLocationUsageDescription</key>
<string>some string</string>

这显示了对话,也适用于 iPhone 模拟器

关于ios - React Native 无权限对话,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45021779/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com