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


#28

yes @notbrent snack is working perfectly fine when standalone in snack, however when i copy and pasted the code from the snack to my project, unfortunately the ‘Missing camera or camera roll permission’ is still there.

@mazerab would you mind sharing whats the “a few settings” in the upgrade guide you talking about?


#29

Thanks @notbrent!
Code working fine.
:man_technologist:t5:


#30

Unfortunately, @notbrent solution does not work with SDK 25. :cry:


#31

@nmacambira You have to upgrade your SDK to 26.

Check out this blog post: Upgrade to Expo SDK v26.0.0

:sweat_smile:


#32

can you share your project?


#33

if you install expo 25.0.1 (npm install expo@25.0.1 --save) this will fix the issue on sdk25, provided that you also request permissions as demonstrated in the snack above (https://snack.expo.io/S1SSmaE6z)


Permissions.getAsync(Permissions.CAMERA_ROLL) "status=denied" when granted
#34

The ones that fixed if for me was the section near the bottom. Below is from the article.

Here’s how to upgrade your app to Expo SDK 27.0.0 from 26.0.0:

Close XDE or your exp CLI server
In app.json, change sdkVersion to "27.0.0"
In package.json, change these dependencies:
- react-native to "https://github.com/expo/react-native/archive/sdk-27.0.0.tar.gz"
- expo to "^27.0.0"
- react to ("16.3.1" — this exact version) 
- react-navigation to "1.5.11" (if you use it, and be sure to peruse the release notes)
- jest-expo to "^27.0.0" (if you use it)
- sentry-expo did not change from "~1.7.0" (if you use it)
Delete your project’s node_modules directory and run npm install again (or use Yarn, we love Yarn)
Reopen your project in XDE and press “Restart” to clear the packager cache, or run exp start -c if you use use exp.
Update the Expo app on your phones from the App Store / Google Play. XDE and exp will automatically update your apps in simulators.
If you use ExpoKit: follow the special upgrade instructions below to get bundled assets when updating an existing ExpoKit project to to SDK 27.
Make sure to check the breaking changes section of this post!

#35

Thanks @notbrent!


#36

@nmacambira I upgraded to SDK 27 to fix my issue.


#37

When we apply the “breaking changes” instructions from 27.0.0 to 25.0.1, we get a mostly working app, but now we periodically get non-native permission modals. Has anyone else experienced this?

The modal says, Experience needs permissions. Sometimes the message says something “App needs permissions for (null),” followed by “You’ve already grated permission to another Expo experience. Allow App to use it also?”

I don’t recall seeing this modal in our production app before, I believe this is a regression.


#38

I’m deploying a patch to our iOS standalone app builders which should eliminate the “Experience needs permissions” regression. It will likely take a couple hours before this gets rolled all the way to production.


#39

The fix is out on prod. Please try rebuilding with exp build:ios and let us know if the issue with the non-system “experience needs permissions” dialog is resolved in the new binary.

If you rebuild and find that you’re still having issues, we may need to wait for further input from @aalices .


#40

Upgrading to sdk 27 didn’t fix the issue for me on iOS. Here is a snack repro: https://snack.expo.io/@hsume2/missing-camera-roll-permission


#41

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


#42

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.


#43

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


#45

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!


#46

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)


#47

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.


#48

@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!