cordova-plugin-scanzy-barcodescanner
v0.0.6
Published
Scanzy Barcode Scanner SDK
Downloads
2
Maintainers
Readme
cordova-plugin-scanzy-barcodescanner
cordova-plugin-scanzy-barcodescanner implements the barcode capture capabilities of the ScanzyBarcodeScannerSDK for iOS and Android. It supports reading a large number of different barcode symbologies, such as Code39, Code93, Code128, Codabar, UPC-A, UPC-E, EAN-8, EAN-13, ITF, QRCode, Aztec, PDF-417, Data Matrix, etc.
Learn more with the documentation or get started with sample
Getting Started
Install the plugin into the ionic cordova project
ionic cordova plugin add cordova-plugin-scanzy-barcodescanner --save
Or install the plugin into the ionic capacitor project
npm install cordova-plugin-scanzy-barcodescanner --save
ionic capacitor sync
Ready to Use
To use this plugin in Javascript:
Firstly, set the license, it's better to do it in your app's startup, although it's fine to call this function every single time when scan the barcode.
ScanzyBarcodeManager.setLicense("YOUR LICENSE KEY");
Then, insert below code snippet into the place to scan barcode:
scan = function () {
var barcodeFormats = [ScanzyBarcodeFormat.Code128,ScanzyBarcodeFormat.Code39];
var barcodeOptions = new ScanzyBarcodeOptions(true, true, true, true, barcodeFormats);
ScanzyBarcodeManager.scan(this.scanSuccess.bind(this), this.scanFailure.bind(this), barcodeOptions);
}
scanSuccess = function (result) {
console.log('scan result:', result.barcode, result.barcodeType);
//your actual business logic to deal with the returned barcode text and barcode type from ScanzyBarcodeScannerSDK
};
scanFailure = function (err) {
//your actual business logic to deal with the returned error from ScanzyBarcodeScannerSDK
};
API Specification
Below gives you more details about the parameters:
The definition of ScanzyBarcodeFormat:
const ScanzyBarcodeFormat = {
Code128:"Code128",
Code39:"Code39",
Code93:"Code93",
CodaBar:"CodaBar",
DataMatrix:"DataMatrix",
EAN13:"EAN13",
EAN8:"EAN8",
ITF:"ITF",
QRCode:"QRCode",
UPCA:"UPCA",
UPCE:"UPCE",
PDF417:"PDF417",
Aztec:"Aztec",
MaxiCode:"MaxiCode"
}
Note: to set the formats you only interested, although you can add ALL formats, it definitely would impact the performance.
The ScanzyBarcodeOptions is defined as:
function ScanzyBarcodeOptions(enableVibration, enableBeep, enableAutoZoom, enableScanCropRectOnly, formats) {
this.enableVibration = enableVibration;
this.enableBeep = enableBeep;
this.enableAutoZoom = enableAutoZoom;
this.enableScanCropRectOnly = enableScanCropRectOnly;
this.formats = formats;
}
enableVibration: vibrate your phone when barcode detected. enableBeep: play the beep sound when barcode detected. enableAutoZoom: the library will zoom in/out automatcially to scan the barcode. enableScanCropRectOnly: only scan the view finder area. formats: the barcode formats.
Support
if you have any questions or need help, check out our official website. Get a free trial license to try. It won't take more than one hour to integrate, insanely simple!