0

I want to use the cordova-plugin-barcodescanner plugin to scan QR code using the front camera. I'm using phonegap and everything is working fine when I test the app using the phonegap mobile app. When I build the the apk file and run the built app on my android device it starts using the back camera. What's more is none of the options are being respected, no option to flip the camera, no flash, etc... Any ideas on how to fix this and make the options work? Thanks.

function QRScan(){
    cordova.plugins.barcodeScanner.scan(
        function (result) {
            alert("We got a barcode\n" +
                  "Result: " + result.text + "\n" +
                  "Format: " + result.format + "\n" +
                  "Cancelled: " + result.cancelled);

            document.getElementById('cryptoId').value = result.text
        },
        function (error) {
            alert("Scanning failed: " + error);
        },
        {
            preferFrontCamera : true, // iOS and Android
            showFlipCameraButton : true, // iOS and Android
            showTorchButton : true, // iOS and Android
            torchOn: true, // Android, launch with the torch switched on (if available)
            saveHistory: true, // Android, save scan history (default false)
            prompt : "Place a barcode inside the scan area", // Android
            resultDisplayDuration: 500, // Android, display scanned text for X ms. 0 suppresses it entirely, default 1500
            formats : "QR_CODE,PDF_417", // default: all but PDF_417 and RSS_EXPANDED
            orientation : "landscape", // Android only (portrait|landscape), default unset so it rotates with the device
            disableAnimations : true, // iOS
            disableSuccessBeep: false // iOS and Android
        }
     );
}
Akaash
  • 31
  • 1
  • 7
  • 1
    Why you don't use QR Scanner Instead of barcode scanner? https://github.com/bitpay/cordova-plugin-qrscanner – parrycima Jul 25 '19 at 14:16
  • Thanks for the suggestion! I've implemented it, it works but messes up all the background styling, the implementation without it being embedded is cleaner. Will use the qrscanner for now but the best would still to be getting the barcodescanner plugin to work. – Akaash Jul 25 '19 at 20:12

1 Answers1

0

It seems that u have installed cordova-plugin-barcodescanner and the options that you are using are from phonegap-plugin-barcodescanner...

Shoaeb
  • 709
  • 7
  • 18