Permissions.AskAsync(CAMERA_ROLL) is granted yet missing camera roll permission is returned

Your snack only uses getAsync. If you want to request the permissions you have to use askAsync

Is there any other way to fix this without having to upgrade? I am currently on "expo": "^24.0.2" and "sdkVersion": "24.0.0". I just woke up one morning and it was broken. I am worried about things breaking by upgrading.

Thank you for catching that. I must be really tired!

Hi @aalices and @ben, I’m in the same situation as of today and it’s still broken. I haven’t changed anything in the Expo SDK or any other versions of React Native, and today on my latest build it just stopped working. Location Services works fine, but both Camera and Camera Roll give the error that OP posted. I’m currently on 24.0.0, so it doesn’t seem to be limited to SDK 25.

Is this something on the Expo build side that is being fixed? I don’t see why a back-end issue that arose from no front-end changes would need an SDK upgrade to resolve…

Also, to clarify, this issue occurs on all stages of development: using the iOS simulator, the Expo iOS app on the phone, using a published Expo app, and when deployed as a standalone app.

Here are my relevant snippets of code:

// this is a snippet of code from a larger function where I ask for permissions

       let {status} = await Permissions.askAsync(Permissions.CAMERA_ROLL);

       // below, GRANTED is just an enum constant for the string 'granted'
       // note that status is coming back as 'granted', and I correctly fall into this block
        if (status === GRANTED ) {
            getImage({dispatch, imageSourceType: imageSourceTypes.CAMERA_ROLL, siteFormType});
        }  

// then the getImage function:

const getImage = async ({dispatch, imageSourceType, siteFormType}) => {
    let result = {cancelled: true};

    // whether I ask for CAMERA or CAMERA_ROLL permissions, both fail here
    // this worked fine until today's build
    if (imageSourceType === imageSourceTypes.CAMERA_ROLL) {

        result = await ImagePicker.launchImageLibraryAsync({
            allowsEditing: true,
            base64: true,
            quality: 0.4
        });
    } else if (imageSourceType === imageSourceTypes.CAMERA) {

        result = await ImagePicker.launchCameraAsync({
            allowsEditing: true,
            base64: true,
            quality: 0.4
        });
    }

    result.hasImage = !result.cancelled;

    return dispatch({
        type: `${siteFormType}_${ADDSITE_IMAGE_UPDATED}`,
        payload: {updatedImage: result}
    });
};

Here’s the error I get when trying to call CAMERA_ROLL

Possible Unhandled Promise Rejection (id: 0):
Error: Missing camera roll permission.
Error: Missing camera roll permission.

And this is the error for CAMERA

Possible Unhandled Promise Rejection (id: 1):
Error: Missing camera or camera roll permission.
Error: Missing camera or camera roll permission.

Thanks!

What is your expo version inside package.json ? Try using 24.0.3 and let us know if this solves this. Did a modal appear? (a custom one, not an iOS-ish one)

I want to +1 for @gmoratorio 's comment. I’m also on SDK 24, and everything worked fine up until just now.

Standard camera roll code, i.e.:

    const { status } = await Permissions.askAsync(Permissions.CAMERA);
    if (status === 'granted') {
      const result = await ImagePicker.launchImageLibraryAsync({
        allowsEditing: true,
        aspect: [4, 4],
        quality: 1,
        base64: true,
        mediaTypes: ImagePicker.MediaTypeOptions.Images,
      });
      if (!result.cancelled) {
        this.props.onImageSelected(result);
      }

I tried specifically updating to Expo 24.0.3 as @aalices suggested (including rimraf node_modules && yarn as well as restarting exp packager and app), but the issue persists. I’ve verified that photo access is indeed granted to the Expo app in iOS settings.

I can’t update to SDK 27, as I’m depending on some backend changes due to the recent Linking API changes, and it might be a while before they’re published.

Diagnostics report:

https://exp-xde-diagnostics.s3.amazonaws.com/brandheroes-shared-8431f5c2-440e-47ca-bff5-8243bbc348ac.tar.gz

Any help would be much appreciated, this is a blocker for my current work. As far as I can tell, this must be something to do with the Expo client, seeing as it’s the only variable with a version change that could’ve broke it as far as I can tell.

@aalices I was on 24.0.0 and just switched to 24.0.3 as you suggested. Looks like that fixed it!

Now working in all stages of development. Thanks for the help!

Update: I managed to succesfully upgrade to SDK 27.0.1, and the issue persists. Again, I’ve removed node_modules, restartet watchman, yarn-installed, restarted XDE and packager, re-installed Expo on simulator.

The exact onPress that is invoked looks like this:

onAddImagePressed = async () => {
    const { status } = await Permissions.askAsync(Permissions.CAMERA);
    if (status === 'granted') {
      const result = await ImagePicker.launchImageLibraryAsync({
        allowsEditing: true,
        aspect: [4, 4],
        quality: 1,
        // @ts-ignore
        base64: true,
        mediaTypes: ImagePicker.MediaTypeOptions.Images,
      });
      if (!result.cancelled) {
        this.props.onImageSelected(result);
      } else {
        console.log(TAG, `image selection cancelled\n`);
      }
    } else {
      // show info to user
    }
  };

Pretty standard setup. Any help would be very much appreciated.

EDIT: I see my error now. Previously, asking for Permissions.CAMERA would also ask for permission to the camera roll, but this must have changed since SDK 24. It works if I use Permissions.CAMERA_ROLL instead.

2 Likes

I was facing the same issue, Upgraded to Version: 27.0.2 and the issue was fixed.

1 Like

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