Search code examples
ios-cameraionic4capacitor

Capacitor - Trying to catch the cancel on camera


I am using Capacitor with Ionic 4 and I would like to catch when the user taps on cancel when on the camera.

public async takePicture(): Promise<string> {

    const image: CameraPhoto = await Camera.getPhoto({
        quality: 90,
        allowEditing: true,
        correctOrientation: true,
        resultType: CameraResultType.Uri,
        source: CameraSource.Camera
    }).catch((e) => {
        throw new Error(e);
    });

    return this._IMAGE = image.webPath;
}

I am simply try to catch and error but clicking on cancel does not throw an error anymore when compared to cordova. How do I catch the cancel on a camera


Solution

  • Sorry, that was a bug, we weren't sending any error on photo cancel for iOS.

    I've sent a PR to fix it, should be fine on next release