Barcode Scanner for cordova

Hi team,

I am facing issue when using barcode scanner plugin for cordova.
I have tried all the below plug in’s and got same error.

cordova-plugin-barcodescanner (this used to work with phonegap app build but no longer working with volt builder build)
phonegap-plugins-barcodescanner
fttx-phonegap-plugin-barcodescanner
cordova-plugin-firebase-ml-kit-barcode-scanner

Below is the code m using

function getQrCode() {
    try {

        document.addEventListener("deviceready", onDeviceReady, false);      
    }
    catch (err) {
            alert(err);
            showError("Failed while reading the QR code " + err);
        }
};


function onDeviceReady() {

    alert("Get QR Code 13");                
    cordova.plugins.barcodeScanner.scan(       
        function (result) {
            //alert("We got a barcode\n" +
            //    "Result: " + result.text + "\n" +
            //    "Format: " + result.format + "\n" +
            //    "Cancelled: " + result.cancelled);
            $(document).find("#filterTable-input1").val(result.text);
            hitSaveButtonBrixReading = 0;
        },
        function (error) {
            alert("Scanning failed: " + error);
        }
    );

}

Getting below error for all plug in’s i have tried so far

Cannot read properties of undefined (reading 'barcodescanner')) when code htis below line
 cordova.plugins.barcodeScanner.scan

Can you please advise which plug in should i use for Bar code scanner that works fine with cordova.

Thanks

Cheers,
Mangi

Tip : If you’re pasting code, html or config files, surround the code with triple back ticks (```), before the first line and after the last one. It will be formatted properly. (We fixed it for you this time)

If barcodeScanner is undefined, you’re using the plugin incorrectly.

Check the documentation for whatever plugin you are using. It will tell you the proper way to reference the plugin in your code.

Hi team,

I have tried to used the below plug in in my app fo scanning barcdoes but still no luck.

Error on the very first line of the below code
Error message: Cannot read properties of undefined(reading ‘GMVBarcodeScanner’)

window.plugins.GMVBarcodeScanner.scan({}, function(err, result) {                  
                //Handle Errors
                if(err) return that.updateResults(err, true);

                //Do something with the data.
                that.updateResults(result);
            });

The above code is from the plugin website itself.

In my config.xml the plug in entry looks like this

  <plugins>
    <plugin name="cordova-plugin-device" value="org.apache.cordova.Device" />
	<plugin name="cordova-plugin-dialogs" value="org.apache.cordova.dialogs" />
    <plugin name="cordova-plugin-network-information" value="org.apache.cordova.network-information" />
	<plugin name="cordova-plugin-whitelist" value="cordova-plugin-whitelist" />
	<plugin name="cordova-gmv-barcode-scanner" value="cordova-gmv-barcode-scanner"  source="npm" spec="1.2.2" />  
  </plugins>

In the build log it shows downloading “cordova-plugin-whitelist” plugin but no entry for any other plug in.

Build logs
Discovered plugin "cordova-plugin-whitelist". Adding it to the project
No scripts found for hook "before_plugin_add".
Calling plugman.fetch on plugin "cordova-plugin-whitelist@^1.3.4"
Copying plugin "/node_modules/cordova-plugin-whitelist" => "/plugins/cordova-plugin-whitelist"
Calling plugman.install on plugin "/plugins/cordova-plugin-whitelist" for platform "android
Installing "cordova-plugin-whitelist" for android
Finding scripts for "before_plugin_install" hook from plugin cordova-plugin-whitelist on android platform only.
No scripts found for hook "before_plugin_install".
Install start for "cordova-plugin-whitelist" on android.
Beginning processing of action stack for android project...
Action stack processing complete.
Install complete for cordova-plugin-whitelist on android.
Finding scripts for "after_plugin_install" hook from plugin cordova-plugin-whitelist on android platform only.
No scripts found for hook "after_plugin_install".
Adding cordova-plugin-whitelist to package.json

I have tried few other ways but getting the same error.
I am not sure what i am doign worng here.

Can someone please adivse how to overcome this problem.
Just to let you know we are on paid plan for Volt builder app.

Cheers,
Mangi

Tip : If you’re pasting code, html or config files, surround the code with triple back ticks (```), before the first line and after the last one. It will be formatted properly. (We fixed it for you this time)

The first thing I notice is that your plugins are surrounded by <plugins> and </plugins> tags. These are not part of the Cordova spec.

Try getting rid of those.

Removing the plugins tag fxied the issue.
thank you so much Team

Thanks for the good news - we’ll add a check for this in VoltBuilder.