react-native - 如何为 react-native-camera 使用 refreshAuthorizationStatus 函数
问题描述
我想从这里使用函数 refreshAuthorizationStatus
如果未授予许可,我还希望有一个回调。谁能帮我这个?我还没有找到一个如何调用这个函数的例子。在我的 react-native 项目中,我的相机有以下设置:
<RNCamera
ref={ref => {
this.camera = ref;
}}
orientation='portrait'
captureAudio={false}
type={RNCamera.Constants.Type.front}
flashMode={RNCamera.Constants.FlashMode.off}
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',
}}
style={styles.camera}>
<TouchableOpacity onPress={this.takePicture.bind(this)}></TouchableOpacity>
</RNCamera>
解决方案
通过以下方式授予的权限: await this.camera.refreshAuthorizationStatus()
,this.camera
作为一个 ref 设置。
this.camera.refreshAuthorizationStatus().then(() => {
//
}).catch((e) =>{
//
}):
推荐阅读
- c - C中pi的无限级数逼近不终止
- java - 使用正则表达式和转义字符拆分 Java 字符串
- php - 根据 Woocommerce 中的产品类别按项目自定义电子邮件通知
- sql-server - 基于总和计算 Percetange
- jquery - js中的ajax调用没有触发
- javascript - 如何使用映射函数 jquery 将 id 与逗号分隔?
- dynamics-crm - 是否可以在 Dynamics crm 的托管解决方案中为自定义实体添加流程?
- equality - 路径之间的平等
- django - pycharm django super().get_context_data(**kwargs) 有错误
- solidity - 配置松露`from`地址的最佳方法