本文介绍了错误:未授予权限... react-native-image-picker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用
执行以下示例代码片段后,我以意外的方式得到了响应.
And after executing the following sample snippet i got the response in an unexpected way.
ImagePicker.showImagePicker(options, response => {
console.log("Response = ", response)
if (response.didCancel) {
console.log("User cancelled image picker")
} else if (response.error) {
console.log("ImagePicker Error: ", response.error)
} else if (response.customButton) {
console.log("User tapped custom button: ", response.customButton)
} else {
const source = { uri: response.uri }
// RNGRP.getRealPathFromURI(response.uri).then(filePath => {
// uploadImageToS3(filePath, "dinesh")
// console.log(filePath)
// })
// You can also display the image using data:
// let source = { uri: 'data:image/jpeg;base64,' + response.data };
this.setState({
avatarSource: source
})
}
响应
-
响应= {错误:未授予权限"}错误:未授予权限" proto :对象D:\ my_app \ index.js:124 ImagePicker错误:未授予权限
RESPONSE
Response = {error: "Permissions weren't granted"}error: "Permissions weren't granted"proto: ObjectD:\my_app\index.js:124 ImagePicker Error: Permissions weren't granted
有时在允许"按钮上按下应用程序意外崩溃.
Sometimes On Allow button press app unexpectedly crashes.
- 原生版本:〜0.46.1
- 反应:16.0.0-alpha.12
- 平台:[Android 5.1及更高版本]
- 开发操作系统:[Windows 7 Professional]
- Dev工具:[Android Studio版本2.3.2,Android SDK 23]
推荐答案
将此代码添加到您的
AndroidManifest.xml
中:Add this code in your
AndroidManifest.xml
:<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
根据Jaffar Raza和szskdgi的建议进行编辑
Edited this after suggestions by Jaffar Raza and szskdgi
这篇关于错误:未授予权限... react-native-image-picker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!