I am sorry to disturb you, I have searched the forum but still did not find the explicit solution;
_pickCameraPrepare = ()=>{
this._pickCameraPermission()
}
_pickCameraPermission = async ()=>{
const { status } = await Permissions.getAsync(Permissions.CAMERA)
const { status: statusRoll} = await Permissions.getAsync(Permissions.CAMERA_ROLL)
if (status === 'granted'&& statusRoll === 'granted') {
this._pickCamera();
} else {
alert('permission denied');
}
}
_pickCamera = async () => {
let result = await ImagePicker.launchCameraAsync({
allowsEditing: true,
aspect: [4, 3],
});
console.log(result);
if (!result.cancelled) {
this.setState({ image: result.uri });
}
};
_pickImagePrepare = () => {
if (Platform.OS === 'ios') {
this._pickImagePermission()
} else {
this._pickImage();
}
}
_pickImagePermission = async () => {
const { status } = await Permissions.getAsync(Permissions.CAMERA_ROLL)
if (status === 'granted') {
this._pickImage();
} else {
alert('permission denied');
}
}
_pickImage = async () => {
let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: 'Images',
allowsEditing: true,
aspect: [4, 3],
});
console.log(result);
if (!result.cancelled) {
this.setState({ image: result.uri });
}
}
the result is on android can access to PhotoLibrary, because there is no need to ask permission, but can’t access to camera on android, PhotoLibrary or camera on ios