React native Android上的CameraRoll

React native Android上的CameraRoll,react-native,react-native-android,camera-roll,React Native,React Native Android,Camera Roll,有没有人使用安卓设备?是否支持Android? 我使用了文档中的示例,但它不起作用 提前谢谢。试试这个 它对我有用 您必须为此请求许可。调用下面的函数(在您的react原生项目上),如果您的应用程序在Android上运行,则调用它(Platform.OS===“Android”?this.requestPhotosPermission():this.getPhotos()) import { PermissionsAndroid } from 'react-native' async requ

有没有人使用安卓设备?是否支持Android? 我使用了文档中的示例,但它不起作用

提前谢谢。

试试这个

它对我有用


您必须为此请求许可。调用下面的函数(在您的react原生项目上),如果您的应用程序在Android上运行,则调用它(
Platform.OS===“Android”?this.requestPhotosPermission():this.getPhotos()

import { PermissionsAndroid } from 'react-native'

async requestPhotosPermission() {
  try {
    const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE)
      if (granted === PermissionsAndroid.RESULTS.GRANTED) {
        this.getPhotos();
      } else {
        console.log("Photos permission denied")
      }
  } catch (err) {
    console.warn(err)
  }
}