1

i am using create-react-native-app and i am having a problem with permissions in trying to get an image from the camera roll.

when i call the method: ImagePicker.launchImageLibraryAsync, i get the error: Missing camera roll permission.

import { ImagePicker } from 'expo';

export const getImageFromLibrary = () => ({
    type: GET_IMAGE_FROM_LIBRARY,
    promise: () => ImagePicker.launchImageLibraryAsync({
        height: '100px',
        width: '100px',
        base64: true
    })
});

the error: Missing camera roll permission. suggests that my app does not have permission, so i then created another button to request permission.

import { Permissions } from 'expo';

<Button
    onPress={() =>
        Permissions.getAsync(Permissions.CAMERA_ROLL)
            .then(console.log)
    }
><Text>get permission</Text></Button>

but when i click on this button i the console.log() method returns with: {status: "granted", expires: "never"}.

this would mean the permission is granted without ever expiring. but the call to get an image from the library is still denied for not having permission.

X0r0N
  • 1,816
  • 6
  • 29
  • 50
  • Try rolling back to version `24.0.3` if you have the latest. I think it is still an open issue in their library. – Pritish Vaidya May 13 '18 at 18:31
  • thanks for your reply. i changed the version of expo to and removed the `node_modules` folder and ran `npm install`. unfortunately this does not work either. the command `Permissions.getAsync(Permissions.CAMERA_ROLL)` now returns a promise containing `{status: "undetermined", expires: "never"}`. – X0r0N May 13 '18 at 19:37
  • You shouldn't need to ask for permission after downgrading. I have asked the Expo team regarding this: https://forums.expo.io/t/why-require-camera-roll-permission-for-imagepicker-in-v27/9744 – Roy Wang May 14 '18 at 02:15
  • this does not fix my issue. i have downgraded to expo version "24.0.3" as suggested. i then ran the command `watchman watch-del-all && rm -rf node_modules && npm install && yarn cache clean`. but even after restarting Expo XDE and the iphone simulator, the issue is still there. – X0r0N May 14 '18 at 06:07

1 Answers1

1

If you can upgrade to expo version 27.0.1 and 28.0.0, then you should be able to see it working.

I tested it with CRNA project. It works fine.

Good luck!

Ken Kosaki
  • 11
  • 2