react-native-camera使用注意事项
react-native-camera的地址:https://github.com/react-native-camera/react-native-camera/blob/master/docs/RNCamera.mdAndroid 6.0以上需要自己手动申请权限Android申请权限方式参考官方说明:<RNCameraref={ref => {this.camera = ref;}
·
react-native-camera的地址:https://github.com/react-native-camera/react-native-camera/blob/master/docs/RNCamera.md
Android 6.0以上需要自己手动申请权限
Android申请权限方式参考官方说明:
<RNCamera
ref={ref => {
this.camera = ref;
}}
style={styles.preview}
type={RNCamera.Constants.Type.back}
flashMode={RNCamera.Constants.FlashMode.on}
androidCameraPermissionOptions={{
title: 'Permission to use camera',
message: 'We need your permission to use your camera',
buttonPositive: 'Ok',
buttonNegative: 'Cancel',
}}
androidRecordAudioPermissionOptions={{
title: 'Permission to use audio recording',
message: 'We need your permission to use your audio',
buttonPositive: 'Ok',
buttonNegative: 'Cancel',
}}
onGoogleVisionBarcodesDetected={({ barcodes }) => {
console.log(barcodes);
}}
/>
苹果也需要申请权限:
苹果申请相机权限的操作为:打开ios下的.xcodeproj文件,使用Xcode打开项目,然后选择target,选择info,找到Privacy-Camera Usage Description, Type自动为String,value就自己填写就行
如果不配置相机权限,那么使用react-native-camera进行拍照或者扫码的时候会闪退
更多推荐



所有评论(0)