[SOLVED] Cordova cordova-plugin-camera and cordova-plugin-media-capture Can't find variable

Hello,

I just update my app to 1.3 and everything is working except cordova-plugin-camera and cordova-plugin-media-capture.

Before the update i was using METEOR@1.3-cordova-beta.2 and everything was working, after the update every time i click(tap) the event to open the camera or the camera roll Uncaught Error: ReferenceError: Can’t find variable: videoCaptureSuccess.

I’m also using cordova-plugin-video-editor.

Here is the error that i receive from xCode.

And here are my file.

My cordova plugins:
cordova-plugin-camera@2.1.1
cordova-plugin-device@1.1.1
cordova-plugin-media-capture@1.2.0
cordova-plugin-video-editor@1.0.8

Thanks in advance

I’m pretty sure what you are dealing with here is a block scoping issue. Changing the way you declare you functions should fix it.

rather than like this which I believe will be handled like declaring with let:

function videoCaptureSuccess() { /*....*/ }

declare the function like this with var to avoid block scope:

var videoCaptureSuccess = function() { /*....*/ }

you could also declare using let or const at the top of the file and then assign later.

let videoCaptureSuccess;

if(Meteor.isCordova){
   videoCaptureSuccess = function() {}
}

Thanks for the help it fix the issue.

1 Like