- SDK Version: Android API 31
- Platforms(Android/iOS/web/all): Android
I’m having a problem with rejected permissions when trying to use ImagePicker.launchCameraAsync.
This is the function that I’m using that works fine with iOS when handling denied permissions: it shows an alert that redirects the user to the settings app to enable permissions. My problem is when I tried to do the same on Android. It asks for both Camera and Library permissions. When I reject the camera permission it works just as expected (the alert shows up and redirects me to the settings) but when I reject the second permission (media) I got an error “Unhandled promise rejection Error: User rejected permissions”. Am I doing something wrong or I do need to handle both permissions on Android when trying to use the camera?
async function handleTakingNewPicture() {
if (!hasCameraPermission) {
const { status } = await ImagePicker.requestCameraPermissionsAsync();
if (status !== 'granted') {
Alert.alert(
'Alert',
'Some alert',
[{ text: 'Ok', onPress: () => Linking.openSettings() }],
);
return;
}
}
const image = await ImagePicker.launchCameraAsync({
allowsEditing: true,
quality: 0.5,
base64: true,
});
console.log('IMAGE', image);
}