我正在使用 react native with expo 构建一个应用程序,其中我需要对 android 上的图片库的许可

问题描述

正如我上面提到的,我无法获得图库的权限,因为根据我收到的错误,CAMERA_ROLL 已被弃用。我在 react native 网站和 expo 文档中搜索了与此相同的整个文档,但我找不到任何有用的东西,所以如果你能向我提供解决方案,这将是一个很大的帮助。这也是我第一次来这里......如果格式不好,请见谅

I have entered the screenshot of the code as you can see CAMERA_ROLL is strikethrough

解决方法

使用 ImagePicker.getCameraPermissionsAsync()ImagePicker.launchCameraAsync() 作为相机

ImagePicker.requestMediaLibraryPermissionsAsync()ImagePicker.launchImageLibraryAsync() 用于图库

查看此处的文档以了解其他选项: https://docs.expo.io/versions/latest/sdk/imagepicker/