i have created a new react native project using expo XDE and i have simply added a button to get camera roll permissions, but it gives an error: Error: Missing camera roll permission.
when i log the return value of the Permissions.askAsync()
method, it tells me the permission is {status: "undetermined", expires: "never"}
.
is it possible to explicitly go into the device’s setting and allow camera roll permissions for the expo app? i am using ios simulator as the device, but i cant find the settings to allow camera roll permission.
my App.js code is as follows:
import React from 'react';
import { StyleSheet, Text, View, TouchableOpacity } from 'react-native';
import { Permissions, ImagePicker } from 'expo';
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
<TouchableOpacity
onPress={() => {
debugger;
console.log(Permissions.CAMERA_ROLL)
return Permissions.getAsync(Permissions.CAMERA_ROLL)
.then((permission) => {
debugger;
return ImagePicker.launchImageLibraryAsync({
height: '100px',
width: '100px',
base64: true
}).then((result) => {
const { base64 } = result;
debugger;
return base64;
}).catch((e) => {
console.log(e);
debugger;
});
}).catch((e) => {
console.log(e);
debugger;
});
}}
><Text>get image</Text></TouchableOpacity>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
on a real device, the permission is returned as {status: "denied", expires: "never"}
. i have gone into the phone settings and i can see that the settings is set to allow full expo access to Photos, Camera, Mobile Data.
i have seen a similar post which seems to be the same issue i am having an suggests the problem is related to to the expo version: https://forums.expo.dev/t/why-require-camera-roll-permission-for-imagepicker-in-v27/9744
in order for me to progress in my work i need to be able to access photos from the photo library/camera, but i am unable to find clear instructions on what i need to do to get this to work.
i have tried different versions the expo version following the compatibility guide, but this does not help. (https://github.com/react-community/create-react-native-app/blob/master/VERSIONS.md
)
i have also tried clearing all the data from the iOS simulator in hopes that it would reset any cached permissions. this did not work either.