Skip to content

Bug on iOS in savePhoto() #167

@ghost

Description

Using CameraPlus v. 4.1.0

There's still a bug in iOS that creates an error when sending a photo taken with the camera back to the calling function. Goal is to save the image in the file-system (not to the camera-roll)

this._owner.get().sendEvent(CameraPlus.photoCapturedEvent, asset);
this.resetPreview();

Sends back an asset that the calling script can't process

I had to change it like this:

this._owner.get().sendEvent(CameraPlus.photoCapturedEvent, this._photoToSave);
this.resetPreview();

Here's the callback in the calling script:

cam.on(CameraPlus.photoCapturedEvent, async (event) => {
        console.log('CameraPlus.photoCapturedEvent', event.data);

        try {

            // let image = event.data;

            if (isIOS) {
                const imageFolder = knownFolders.documents();

                console.log('event-data', event.data);

                const iosImage = UIImageJPEGRepresentation(event.data, 0.7);

                const result1 = NSFileManager.defaultManager.createFileAtPathContentsAttributes(imageFolder.path + "/cam_capture.jpg", iosImage, null);

                const asset = new ImageAsset(imageFolder.path + "/cam_capture.jpg");

                console.log('asset', asset);

                currentAsset = asset;

                viewModel.previewImage = asset;
                viewModel.didTakePicture = true;
                viewModel.canTakePicture = false;

                console.log('ios-image', asset);


            } 

        } catch (error) {
            console.error('error', error);
        }
    });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions