如何创建 link 以响应原生相机

How to create link to camera react native

我在 react-native 中找到了摄像头 API:react-native-camera API 允许在组件内部安装摄像头。但我不喜欢这样,因为默认情况下它没有设备的相机应用程序。我只想通过单击按钮打开设备的相机应用程序。可能吗?

试试这个 NPM react-native-image-picker

import ImagePicker from "react-native-image-picker";
export function showImagePickerDialog(darkMode) {
  return new Promise((resolve, _) => {

    const options = {
      title: 'Capture image',
      storageOptions: {
        skipBackup: true,
        path: "images"
      },
      mediaType: 'photo',
      videoQuality: 'high',
      durationLimit: 10,
      maxWidth: 1000,
      maxHeight: 1000,
      allowsEditing: false,
      noData: true,
      quality: 0.8,
      tintColor: darkMode ? colors.colorWhite : colors.colorBlack,
    };
    ImagePicker.showImagePicker(options, response => {

      if (response.didCancel || response.error) {
        resolve(false);
      }
      else {
        resolve(response);
      }
    })
  })
}