Is anyone else frustrated that cordova calls only work from within Meteor.startup()?
I have been trying to call the barcode scanner from a button click. It just doesn’t return to the called functions. I finally noticed this integration document and tested having the barcode scanner called from Meteor.startup and the scanner works and returns correctly.
Is there another way to do this? I still want the scanner called from my button.
I think you just have a bug, please show what you tried.
You cannot call Cordova methods just plain the the source code. That makes sense because: It just did not have the time yet to load everything.
Then Meteor.startup gets called. From that moment you are ready to use the scanner.
So, if you call it from a event handler it should also just work. Because that is also after the startup moment. So I suspect a bug in the code.
Also it might be good to code defensive, so maybe add some checks like: if(!MyBarcodeObject) to give you clear error messages when there are loading issues.
The call to barcodescanner.scan works, but does not call function(result) in the case of a button click. It only works and returns the result when called from Meteor.startup().
More testing… The call to the scanner also works from function onDeviceReady() but only when device ready is called from startup. Just not on the button click.