Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(camera): Camera.requestPermissions() hangs on Android 33+ #2140

Open
1 of 3 tasks
stefanMinch3v opened this issue Jun 8, 2024 · 6 comments
Open
1 of 3 tasks

bug(camera): Camera.requestPermissions() hangs on Android 33+ #2140

stefanMinch3v opened this issue Jun 8, 2024 · 6 comments

Comments

@stefanMinch3v
Copy link

stefanMinch3v commented Jun 8, 2024

Capacitor Version

6

Other API Details

No response

Platforms Affected

  • iOS
  • Android
  • Web

Current Behavior

When I click the button to pick an image from the gallery nothing happens

Expected Behavior

When i click the button to pick an image from the gallery it shows a pop-up to allow reading images and then select the image

Project Reproduction

https://github.com/stefanMinch3v/capacitor-bug-image-gallery/tree/main

Additional Information

On capacitor 5 the code below works as expected. It requests permission to read from gallery and then shows the gallery to pick an image. With capacitor 6, on button click nothing happens

With only these 2 permissions in the AndroidManifest.xml file
uses-permission android:name="android.permission.READ_MEDIA_IMAGES"
uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"

Android version tested - 12 (works here), 13 (not working) and 14 (not working)

`async selectImage(): Promise {

try {
  await Camera.requestPermissions();
} catch {
  // do nothing
}

let img: Photo = null;

try {
  img = await Camera.getPhoto({
    quality: 90,
    allowEditing: false,
    resultType: CameraResultType.Base64,
    source: CameraSource.Photos
  });
} catch {
  // cancel image from gallery
}

if (img) {
 // continue the flow below
}

}`

Any idea how should I proceed here, do I need to add some extra code or permissions to the manifest file?
Thank you

Copy link

ionitron-bot bot commented Jun 10, 2024

This issue needs more information before it can be addressed. In particular, the reporter needs to provide a minimal sample app that demonstrates the issue. If no sample app is provided within 15 days, the issue will be closed.
Please see the Contributing Guide for how to create a Sample App.
Thanks! Ionitron 💙

@stefanMinch3v

This comment was marked as abuse.

@botrot
Copy link

botrot commented Jun 17, 2024

Hello,
our team is experiencing the same issue, is there any progress on the bug, just to know what to tell our users.

@Lasseroenn
Copy link

We are experiencing the same issue. Any updates?

@jcesarmobile
Copy link
Member

@capacitor/camera 6 no longer requires permissions for picking pictures, see the breaking changes section of Capacitor 6 upgrade guide for Camera plugin https://capacitorjs.com/docs/updating/6-0#camera

So if you remove the await Camera.requestPermissions(); the picker will work.

But the Camera.requestPermissions(); should not hang on Android 33+, that should be fixed.

@jcesarmobile jcesarmobile transferred this issue from ionic-team/capacitor Jun 21, 2024
@jcesarmobile jcesarmobile changed the title [Bug]: Capacitor 6 get image from gallery pop-up does not work anymore bug(camera): Camera.requestPermissions() hangs on Android 33+ Jun 21, 2024
@botrot
Copy link

botrot commented Jun 24, 2024

Is it safe to use without requesting permissions to read from camera/gallery, I thought it should always ask the user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants