Search code examples
ionic-frameworkcapacitor

Ionic Capacitor: How to restrict Gallery from Camera options?


for an app that I'm building, I'm using Capacitor's Camera plugin. When I click the button that launches the camera, it's asking me to first choose between Gallery and Camera.

I'd like to turn the "Pick from Gallery" feature off. Is there any solution for this?

enter image description here


Solution

  • By default the Camera plugin prompts, but you can select Camera or Gallery by passing the source attribute

    // The source to get the photo from. By default this prompts the user to select either the photo album or take a photo. Default: CameraSource.Prompt
    source ?: CameraSource;
    

    Full example:

    const image = await Camera.getPhoto({
        quality: 90,
        resultType: CameraResultType.Uri,
        source: CameraSource.Camera
    });