Well, I need to use the camera & camera roll in my app, so the user can load profile pictures. I followed the expo examples & make some research, but I can’t found why it doesn’t work in IOS standalone app.
A fresh install of the app ask for the permissions and, after accepted them, you can access the camera OR the camera roll, but only once. The second time nothing happens, nor errors nor nothing.
For example: user accepts the permissions, open the camera, close it or take a picture, try to access again the camera or the camera roll and nothing happens
Locally it works
I leave an example code:
- Get the permissions.
- Check if both are granted
- If not, ask for the permissions
askPermissionsAsync = async () => {
const { status, permissions } = await Permissions.getAsync(Permissions.CAMERA, Permissions.CAMERA_ROLL);
if (status !== 'granted') {
if (permissions[Permissions.CAMERA].status !== 'granted') {
const cameraPermission = await Permissions.askAsync(Permissions.CAMERA);
if (cameraPermission.status !== 'granted') {
this.setState({
errorMessage: 'Permission to access the camera was denied',
});
}
}
if (permissions[Permissions.CAMERA_ROLL].status !== 'granted') {
const cameraRollPermission = await Permissions.askAsync(Permissions.CAMERA_ROLL);
if (cameraRollPermission.status !== 'granted') {
this.setState({
errorMessage: 'Permission to access the camera roll was denied',
});
}
}
}
}
pickImage = async () => {
await this.askPermissionsAsync();
const result = await ImagePicker.launchImageLibraryAsync();
!result.cancelled && this.handleImagePicked(result.uri);
}
takePhoto = async () => {
await this.askPermissionsAsync();
const result = await ImagePicker.launchCameraAsync();
!result.cancelled && this.handleImagePicked(result.uri);
}
I can share a video of the problem in the standalone app, if needed.
Thanks in advance!