Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug on iOS in savePhoto() #167

Open
update-switzerland opened this issue Oct 5, 2021 · 0 comments
Open

Bug on iOS in savePhoto() #167

update-switzerland opened this issue Oct 5, 2021 · 0 comments

Comments

@update-switzerland
Copy link

update-switzerland commented Oct 5, 2021

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);
        }
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants