我刚刚开始使用expo图像选择器,但出于测试目的,我已经多次拒绝相机权限,因此不再有人问我是要允许还是拒绝该权限。我刷新了,重新启动了应用程序,但没有做
Sample.js
import {TouchableOpacity} from "react-native";
import React from "react";
import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
import FontAwesome5 from "react-native-vector-icons/FontAwesome5";
import * as ImagePicker from "expo-image-picker";
const Sample = ({ navigation }) => {
const handleUpload = async () => {
let permissionResult =
await ImagePicker.requestMediaLibraryPermissionsAsync();
console.log(permissionResult);
if (permissionResult.granted === false) {
alert("Camera access required");
return;
}
};
return (
<KeyboardAwareScrollView>
<TouchableOpacity onPress={handleUpload}>
{image && image.url && (
<FontAwesome5
name="camera"
size={20}
color="black"
style={{ marginTop: -20, marginLeft: 200, marginBottom: 30 }}
/>)}
</TouchableOpacity>
</KeyboardAwareScrollView>
);
};
export default Sample ;
转到相应的应用程序设置并清除数据。它很可能会重置权限。你也可以尝试卸载应用程序并重新安装。
如果你在询问如果用户这样做该怎么办(很可能他们不会这样做(,你必须将用户引导到应用程序的设置页面,并手动允许权限。
我相信您需要卸载并重新安装才能再次收到此提示。