无法读取未定义的属性 getPermissionStatus |反应本机权限 [英] Cannot read property getPermissionStatus of undefined | react-native-permissions
问题描述
使用
我直接使用 react-native-permissions README 中的代码
componentWillMount() {Permissions.check('photo').then(response => {控制台日志(响应);});}
我使用 react-native link 来链接它.
react-native 链接 react-native-permissions
我很确定它链接正确,因为当我调用 Permissions.getTypes()
componentWillMount() {console.log(Permissions.getTypes());}
我收到以下回复:
React 原生版本: 0.53.0
React Native 权限版本: 1.1.1
Podfile
# 取消下一行的注释,为你的项目定义一个全局平台平台:ios,'10.0'目标myApp"做pod '条纹', '~>11.2.0'pod 'RNVectorIcons', :path =>'../node_modules/react-native-vector-icons'pod 'BVLinearGradient', :path =>'../node_modules/react-native-linear-gradient'pod 'ReactNativePermissions', :path =>'../node_modules/react-native-permissions'结尾
编辑
- 我将 React Native 降级为 0.52.0,因为这是 react-native-permissions 更新自述文件的最后一次,但我仍然遇到相同的错误.
事实证明,
Permissions.getTypes()
无需链接即可工作.
我最终不得不按照此处的手动链接说明进行操作:使用手动链接
<块引用>使用手动链接
在 XCode 的项目导航器"中,右键单击项目的库文件夹 ➜ 将文件添加到 <...>转到 node_modules ➜ react-native-permissions ➜ 选择 ReactNativePermissions.xcodeproj将 libReactNativePermissions.a 添加到构建阶段 ->将二进制文件与库链接
I'm getting this error when calling Permissions.check() using the react-native-permissions library
I'm using the code straight from the react-native-permissions README
componentWillMount() {
Permissions.check('photo').then(response => {
console.log(response);
});
}
I used react-native link to link it.
react-native link react-native-permissions
I'm pretty sure it's linked correctly because when I call Permissions.getTypes()
componentWillMount() {
console.log(Permissions.getTypes());
}
I get the following response:
React Native Version: 0.53.0
React Native Permissions Version: 1.1.1
Podfile
# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'
target 'myApp' do
pod 'Stripe', '~> 11.2.0'
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'
pod 'ReactNativePermissions', :path => '../node_modules/react-native-permissions'
end
Edits
- I downgraded React Native to 0.52.0 as that's the last react-native-permissions updated their README and I still get the same error.
It turns out,
Permissions.getTypes()
works without linking.
I ended up having to follow the manual linking instructions here: using manual linking
Using manual linking
In the XCode's "Project navigator", right click on your project's Libraries folder ➜ Add Files to <...> Go to node_modules ➜ react-native-permissions ➜ select ReactNativePermissions.xcodeproj Add libReactNativePermissions.a to Build Phases -> Link Binary With Libraries
这篇关于无法读取未定义的属性 getPermissionStatus |反应本机权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!