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

NSInvalidArgumentException - App crashes when CaptureImage is called #157

Open
attex opened this issue Nov 22, 2019 · 1 comment
Open

NSInvalidArgumentException - App crashes when CaptureImage is called #157

attex opened this issue Nov 22, 2019 · 1 comment

Comments

@attex
Copy link

attex commented Nov 22, 2019

Bug Report

Hi guys,

recently I am facing the Issue that my app crashes when I am trying to call the function "captureImage". The function did in fact work for quite some time, so I don't actually know why it doesn't anymore.

`
function captureImage(storePath) {

try {
    var newPath = storePath;
    var captureSuccess = function (mediaFiles) {
        var i, path, len;
        for (i = 0, len = mediaFiles.length; i < len; i += 1) {
            path = mediaFiles[i].fullPath;
            let name = new Date().getTime();
            moveFile(path, FILE_DIRECTORY + newPath, name + ".jpg");
        }
    };
    // capture error callback
    var captureError = function (error) {
        navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
    };
    // start image capture
    navigator.device.capture.captureImage(captureSuccess, captureError, { limit: 1 });
} catch(e) {
    console.log(e);
}

}
`

The app doesn't even Catch the exception. Instead it just crashes. And leaves me this error-message:

"*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller <MainViewController: 0x101513700>.'"

The "NSInvalidArgumentException" kinda confuses me a bit, as it seems like I am passing some wrong functions for success and error. But as mentioned before this code worked for me like for more than a year and I did not change anything since then.

Cordova version: 9.0.0
Cordova-Ins version: 4.5.5
iOS Version: 13.2.3
Device: iPad (6. Gen)

@Davide153
Copy link

Have you came up with a solution? I'm facing the same problem...

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

2 participants