Capacitor Camera to not show prompt dialogue

Viewed 485

I am using the camera plugin from Capacitor with angular in order to save images locally from both desktop and tablet. I want to be able to use the CameraSource to directly open the camera or open the file gallery and to not show the prompt.

My code looks like this:

My A.html

<button (click)="addPhoto('Camera')">Capture Image</button>
<button (click)="addPhoto('Photos')">Choose from Gallery</button>

A.ts

import { CameraDirection, CameraResultType, CameraSource, Plugins } from '@capacitor/core';

const { Camera } = Plugins;

async addPhoto(source) {
  if (source === 'Camera') {
      const image = await Camera.getPhoto({
      quality: 90,
      source: CameraSource.Camera
      resultType: CameraResultType.Uri
    });
  } else if ( source === 'Photos') {
      const image = await Camera.getPhoto({
      quality: 90,
      source: CameraSource.Photos
      resultType: CameraResultType.Uri
    });
  }
}

Somehow Capacitor ingores my source property. Is my desired behaviour even possible?

1 Answers

You might be missing a comma after the source parameter

Related