Expo XDE React-Native CAMERA_ROLL Permission `undetermined`

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.

Hi xoron, what version of the Expo SDK are you using? I believe there was an issue in version 25, if that’s your case. I also believe @aalices would know the most about this.

i am using a fresh setup using expo XDE. the package.json is:

{
  "main": "node_modules/expo/AppEntry.js",
  "private": true,
  "dependencies": {
    "expo": "^27.0.1",
    "react": "16.3.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-27.0.0.tar.gz"
  }
}

Hello @xoron , the code you attached only includes getAsync, are you using askAsync somewhere else?

great! that worked. thanks.

i should have read the documentation more clearly. i will add link to the documentation in case someone else stumbles onto this thread: https://docs.expo.io/versions/latest/sdk/permissions

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.