ImagePicker.launchCameraAsync does not work

#1

This is the same problem reported in some of the posts of Permissions.AskAsync(CAMERA_ROLL) is granted yet missing camera roll permission is returned

I am using expo 30.0.1.

Here is my code:

pickPhoto = async() => {
    let { status } = await Permissions.getAsync(Permissions.CAMERA);
    console.log('status of Camera permission: ', status);
    if (status !== 'granted') {
      console.log('Camera permission not granted!');
      console.log('Asking for permission');
      status = await Permissions.askAsync(Permissions.CAMERA).status;
      if (status !== 'granted') {
        console.log('Asked for permission, but not granted!');
        return;
      }
    }

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

I am running in debug mode, and on an android 8 smartphone I am getting:

[19:25:43] status of Camera permission:  denied
[19:25:43] Camera permission not granted!
[19:25:43] Asking for permission
[19:25:43] Asked for permission, but not granted!

While this is being printed to the console, a popup on the smartphone asks for the permission, but the app doesn’t wait to get the answer…

I am granting the permission, and when running the app again, I get:

[19:26:10] status of Camera permission:  granted

[19:26:14] [Unhandled promise rejection: Error: User rejected permissions]
- node_modules\react-native\Libraries\BatchedBridge\NativeModules.js:121:42 in createErrorFromErrorData
- node_modules\react-native\Libraries\BatchedBridge\NativeModules.js:78:57 in <unknown>
- ... 5 more stack frames from framework internals

Does anyone have a problem with version 30 of expo? Or previous version?

#2

Hey @rahamin,

Forgive me if I’m mistaken, but nowhere in your code you posted are you asking for CAMERA_ROLL permission that is required to use launchCameraAsync https://docs.expo.io/versions/v30.0.0/sdk/imagepicker#expoimagepickerlaunchcameraasyncoptions

Cheers,

Adam

1 Like
#3

Hi @adamjnav

Thanks a lot, this was it! My fault…

Cheers
Yossi

1 Like
#4

No worries! Glad we got it figured out.

closed #5

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