Cordova plugin to manage the scanner on a U8000S device.
The plugin can be installed via Cordova-CLI.
Execute from the projects root folder:
$ cordova plugin add https://github.com/syware/cordova-plugin-scanner-u8000s.git
To remove the plugin
$ cordova plugin remove cordova-plugin-scanner-u8000s
The plugin creates the object ScanPlugin and is accessible after deviceready has been fired.
document.addEventListener('deviceready', function () {
// ScanPlugin is now available
}, false);When the scanner is enable, it allows you to trigger the scan with the hardware key
// Enable
ScanPlugin.openScanner();
// Disable
ScanPlugin.closeScanner();To catch the barcode you should set a callback with the register function
// Register a callback to manage the scan object
ScanPlugin.register(
function (barcode) {
console.log(barcode) // What barcode was scanned
},
function (error) {
console.log(error) // Catch the error
}
)When the callback is fired, you have to set it again to catch the next barcode
With that function you can trigger the scan by software
// Trigger the scanner manually (by software)
ScanPlugin.startDecode(
function (barcode) {
console.log(barcode) // What barcode was scanned
},
function (error) {
console.log(error) // Catch the error
}
)
// Stop the scanner
ScanPlugin.stopDecode()This software is released under the Apache 2.0 License.
© 2017 Syware Sàrl