Hello all!
Although for both CAMERA and CAMERA_ROLL status returns granted, it doesn’t open the camera on IOS, iPad.
I’m using SDK 33.
The relevant part of the code is below. And I have two buttons, one for enableCameraRollPicker and the other one for takeImage function.
Thanks in advance!
import Constants from 'expo-constants';
import * as Permissions from 'expo-permissions';
import * as ImagePicker from 'expo-image-picker';
getPermissionAsync = async () => {
if (Constants.platform.ios) {
const { status: cameraRollStatus } = await Permissions.askAsync(Permissions.CAMERA_ROLL);
if (cameraRollStatus !== 'granted') {
alert('Sorry, we need camera roll permissions to make this work!');
}
const { status: cameraStatus } = await Permissions.askAsync(Permissions.CAMERA);
if (cameraStatus !== 'granted') {
alert('Sorry, we need camera permissions to make this work!');
}
}
}
enableCameraRollPicker = async () => {
const { ApplicationState } = this.props;
await this.getPermissionAsync();
ApplicationState.setOptionsModalActive(false)
ApplicationState.setCameraRollPickerActive(true);
}
takeImage = async () => {
const { ApplicationState } = this.props;
await this.getPermissionAsync();
ApplicationState.setOptionsModalActive(false);
const result = await ImagePicker.launchCameraAsync({
mediaTypes: ImagePicker.MediaTypeOptions.All,
exif: true
});
if (!result.cancelled) {
console.log(result);
ApplicationState.setPhotosToPost([{
uri: result.uri,
description: null,
}]);
this.enableDescriptionModal();
}
}