How can I prevent user to pick a picture from gallery?

When taking a picture I must force the user to take a picture use the camera and prevent them from picking one that has been already stored in the device.

My guess was that the above was achieved by setting source to CameraSource.Camera as in

const image = await Camera.getPhoto({

    quality: 40,

    source: CameraSource.Camera,

    allowEditing: false,

    resultType: CameraResultType.Uri

    });

But user can still choose one from the gallery by clicking on the gallery button.

Is there a way to achieve this with capacitor?

1 Like

Right now, that isn’t supported, unfortunately. To get around this, you can check the image’s EXIF data to see the date and time the photo was taken. If it wasn’t taken within a minute or so of the current time, you could re-prompt the user to take the photo.

1 Like

Thanks @thomasvidas . EXIF file is an option but would like to avoid explaining to the client why the user still can access the gallery…

Is there a way for me to edit the pwa camera modal and just remove the button from the html or disable the onclick function?

So far I have found this files referencing the modal:
p-lncw1afo.entry.js
p-kams8vbu.system.entry.js

However I edited them deleting the pick-image class with no success… don’t know what I am doing really… just a mortal coder playing (programming) god…

1 Like

Just checked EXIF and there seems to be an issue with capacitor that makes it lose some EXIF tags… like dates

See EXIF Data Stripped From Images · Issue #45 · ionic-team/capacitor-plugins · GitHub and GitHub - dtarnawsky/capacitor-exif-test: test exif reader within capacitor

So I am betting on modifying the pwa modal right now

1 Like

Still stuck. EXIF tags do not include lastModified date or similar and I haven’t been able to modify the html of the modal.

Any suggestions?

1 Like