cordova-plugin-barcodescanner scan options work in phonegap mobile app and stop working after build

6.1k Views Asked by At

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
        }
     );
}
1

There are 1 best solutions below

0
Shoaeb On

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