My problem is that when I start the app on my Nexus 5 via ionic run and click my test button I get a generic error message saying that there has been a problem with the Android camera and that it could help to reboot the device.
A screenshot of the message (sorry for it being in German):
What version of android do you use? Latest android version need to asign permissons to the app.
I had the same problems with android 6.0.1. When you allow your app to make use of the camera the problem should be gone and u can start scanning barcodes!
Thanks for the hint.
I tried to request the permission in two ways which both failed:
Version 1:
I added BarcodeScanner.requestCameraPermission(); to my test function. This caused the error Error TS2339: Property 'requestCameraPermission' does not exist on type 'typeof BarcodeScanner'..
Version 2:
I added cordova.plugins.barcodeScanner.requestCameraPermission(); to my test function. This resulted in the error Error TS2304: Cannot find name 'cordova'. 7.5 MB bytes written (12.23 seconds).
Looks like you are missing some typing files. At least for the second error. Do you have typings installed? npm install -g typings try to install cordova typings install cordova --save --ambient
Note that backward compatibility was added by checking for permission in the scan function. If permission is needed the scan method will now show the permission request popup. The user will then need to allow camera access and launch the scanner again.
Thanks for the suggestion. I executed the commands you suggested but that only changed my second error message to Error TS2339: Property 'barcodeScanner' does not exist on type 'CordovaPlugins'..