Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async _requestCameraPermission() {
try {
const permissionGranted = await Camera.checkVideoAuthorizationStatus()
this.setState({permissionGranted})
} catch (err) {
console.warn("Can't get camera permissions", err)
this.setState({permissionGranted: false})
}
}
componentDidMount() {
Camera.checkVideoAuthorizationStatus().then(data => {
console.log(data);
this.setState({ allowed: data });
});
}
async _requestCameraPermission() {
try {
const permissionGranted = await Camera.checkVideoAuthorizationStatus()
this.setState({permissionGranted})
} catch (err) {
logger.warn("Can't get camera permissions", err)
this.setState({permissionGranted: false})
}
}
checkCameraAuthorization = () => {
if (Platform.OS === 'ios') {
Camera.checkVideoAuthorizationStatus()
.then((authorization: boolean) => {
if (authorization) {
this.setHasCameraAccessPermission()
} else {
this.setNoCameraAccessPermission()
}
})
.catch(this.setNoCameraAccessPermission)
} else {
PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.CAMERA, {
title: 'App Camera Permission',
message:
'App needs access to your camera ' +
'so you can scan QR codes and form connections.',
})
.then(result => {