我使用的是react-native-permissions,当应用最初加载时,它会请求用户摄像头权限,以防万一用户拒绝它,在提示需要说明的警报发出后,应用会将其导航到应用设置相机。
在用户打开相机权限并返回到android应用后,什么也没有发生,并且该应用冻结了。 在iOS上,应用返回流程。
requestCameraPermission = async () => {
try {
const response = await Permissions.request('camera');
if (response === 'denied' || response === 'blocked') {
alert("...",Please enable phone's camera.",'',() => OpenAppSettings.open());
return false
} else {
return true
}
} catch (e) {
alert(e.message)
}
};
在我的App.js componentDidmount中,我将此函数称为:
requestCameraPermission = async () => {
const {loadingFlow} = this.props.rootStore.flowStore;
const permission = await this.props.rootStore.permissionStore.checkCameraPermission();
if (permission) {
loadingFlow((route) => {
//do stuff here and then navigates. (this part works on iOS but not on android)
});
}
};