Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async componentDidMount() {
await this.styler.init();
const { status } = await Permissions.askAsync(Permissions.CAMERA);
this.setState({
hasCameraPermission: status === 'granted',
isLoading: false
});
}
handleTakeImage = () => {
Permissions.askAsync(Permissions.CAMERA_ROLL, Permissions.CAMERA)
.then((response) => {
const { status, expires, permissions } = response
if (status === 'granted') {
ImagePicker.launchCameraAsync({
allowsEditing: true,
aspect: [1, 1],
base64: true,
quality: 0.5,
})
.then((response) => {
if (!response.cancelled) {
this.props.uploadImage(response.uri)
}
})
.catch((error) => console.log(error))
}
async componentDidMount() {
const { status } = await Permissions.askAsync(Permissions.CAMERA);
this.setState({ hasCameraPermission: status === 'granted' });
}
export async function requestCameraAysnc() {
return await controlledPromptAsync(
Permissions.CAMERA,
'In order to take photos you need to grant access to the camera'
);
}
const ConnectedCameraScreen = connect(({ camera, permissions }) => ({
camera,
hasPermission:
permissions[Permissions.CAMERA] === 'granted' &&
permissions[Permissions.AUDIO_RECORDING] === 'granted',
}))(CameraScreen);
const getPermissionsGranted = async () => {
const {status} = await Permissions.askAsync(Permissions.CAMERA)
setHasCameraPermission(status === 'granted')
}
getPermissionsGranted()
export async function takePictureAsync(onSend) {
if (await getPermissionAsync(Permissions.CAMERA)) {
const result = await ImagePicker.launchCameraAsync({
allowsEditing: true,
aspect: [4, 3],
})
if (!result.cancelled) {
onSend([{ image: result.uri }])
return result.uri
}
}
}
public async componentWillMount() {
const { status } = await Permissions.askAsync(Permissions.CAMERA);
this.setState({
hasPermissionToCamera: status === "granted"
});
}