I want user to select a profile picture using either camera or photo gallery. I use react-native-image-picker to give user choice.....using below code:
import ImagePicker from 'react-native-image-picker';
export const _imagePickHandler = userId => {
const options = {
title: 'Select Profile Pic',
takePhotoButtonTitle: 'Take photo with your camera',
chooseFromLibraryButtonTitle: 'Choose photo from library',
};
ImagePicker.showImagePicker(options, async imgPickResponse => {
if (imgPickResponse.didCancel) {
console.log('User cancelled image picker');
} else if (imgPickResponse.error) {
console.log('Image Picker Error: ', imgPickResponse.error);
} else {
//code for success
}
});
};
When user click 'deny', imgPickResponse.error
returns Permissions weren't granted
.....and this is expected.
However the problem comes when user clicks 'deny and never ask again'.....imgPickResponse.error
AGAIN returns Permissions weren't granted
. However if user has chosen this I want a different course of action.
ALSO...if I use the check()
method from react-native-permissions
in the callback function for showImagePicker()
I get the same issue; regardless of whether user has 'denied' or 'denied and never ask again' I get the same response of 'denied'....it does not give me 'blocked' as Id expect.
See code below
export const _checkPermissions = async permission => {
let result = await check(
Platform.select({
android: PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE,
ios: PERMISSIONS.IOS.PHOTO_LIBRARY,
}),
);
return result;
};
Im using react-native-permissons version 2.1.5
Finally, here is my AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name = "android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>