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

[nativescript-camera-plus][ios] - wrong format of file when photo is taken. #146

Open
swissdude opened this issue Jan 23, 2024 · 0 comments

Comments

@swissdude
Copy link

I ran into an issue when I was using the plugin on iOS. When the picture was taken and I tried to save it to a folder, I got an error saying: error Error: -[DictionaryAdapter _rasterizedImage]: unrecognized selector sent to instance 0x283f1ea90

The code I'm using:

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);

So I had to change the file index.ios.js to the following:

import { Color, isAndroid, Device, File, ImageAsset, knownFolders, path, Utils, View } from '@nativescript/core';
(import isAndroid)

Then, in the savePhoto function I changed the const handleSuccess function to this:

const handleSuccess = () => {

                if (!isAndroid) {
                    this._owner.get().sendEvent(CameraPlus.photoCapturedEvent, this._photoToSave);
                } else {
                    this._owner.get().sendEvent(CameraPlus.photoCapturedEvent, asset);
                }
                this.resetPreview();
            };

This gets rid of the 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

1 participant