在React Native Image Picker中获取response.error

时间:2019-07-28 08:01:34

标签: react-native react-native-android react-native-ios

我正在使用React Native Image Picker,但在响应“无法启动照片库”时收到此错误

React本机版本= 0.60.3

这是我的代码

handleProfilePicture = async () => {
const options = {};

try {
  const granted = await PermissionsAndroid.request(
    PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE ||
      PermissionsAndroid.PERMISSIONS.CAMERA,
    {
      title: 'Wants to access your gallery',
      buttonNeutral: 'Ask Me Later',
      buttonNegative: 'Cancel',
      buttonPositive: 'OK'
    }
  );
  if (granted === PermissionsAndroid.RESULTS.GRANTED) {
    ImagePicker.showImagePicker(options, res => {
      console.log('response', res);
    });
  } else {
    console.log('Gallery permission denied');
  }
} catch (err) {
  console.warn(err);
}

};

0 个答案:

没有答案