Hello,
ImagePicker.launchImageLibraryAsync and ImagePicker.launchCameraAsync methods do not always work when having permissions… I have been testing it with development and debugging enabled and it works just fine. However if I switch to production mode it stops working. Neither that nor alert() methods. This works just fine for Android but not for iOS.
onTakePicturePress = async () => {
const cameraRollPerms = await Permissions.askAsync(Permissions.CAMERA_ROLL);
const cameraPerms = await Permissions.askAsync(Permissions.CAMERA);
if (cameraRollPerms.status === "granted" && cameraPerms.status === "granted") {
const options = {
mediaTypes: 'Images',
allowsEditing: true,
aspect: [1, 1]
};
let response = await ImagePicker.launchCameraAsync(options);
if (!response.cancelled) {
this.props.onClientDataValueChange({
prop: 'profilePicture',
value: response.uri
});
this.setState({ newProfilePicture: true });
}
} else {
alert('Sorry, we need camera roll permissions to make this work!')
}
};
onChoosePicturePress = async () => {
if (Constants.platform.ios) { // Android does not need these permissiosn
const { status } = await Permissions.askAsync(Permissions.CAMERA_ROLL);
if (status !== 'granted') {
alert('Sorry, we need camera roll permissions to make this work!');
return;
}
}
const options = {
mediaTypes: 'Images',
allowsEditing: true,
aspect: [1, 1]
};
let response = await ImagePicker.launchImageLibraryAsync(options);
if (!response.cancelled) {
this.props.onClientDataValueChange({
prop: 'profilePicture',
value: response.uri
});
this.setState({ newProfilePicture: true });
}
};
Thanks in advance for the help!