react-native-scanzy-barcode-scanner-plugin v0.0.4
react-native-scanzy-barcode-scanner-plugin
react-native-scanzy-barcode-scanner-plugin 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
Prerequisites
- Install Node.js which includes Node Package Manager, version 14 or higher
- Android development: Install Android Studio
- iOS development: Install XCode
- ios development: Install CocoaPods
- This project uses React Native as app development platform and the npx.
Installation
npm install react-native-scanzy-barcode-scanner-plugin
For ios project, in order to get camera permission, please add below configs to the Info.plist of the Project Targets.
<key>NSCameraUsageDescription</key>
<string>camera description.</string>
For android project, add the following config in the same build.gradle(Android/app/build.gradle) file to avoid conflicts with the lib filename libc++_shared.so, which is used by React Native as well as by many other 3rd-party modules:
android {
...
packagingOptions {
pickFirst '**/libc++_shared.so'
}
}
Usage
import ScanzyBarcodeManager, {ScanzyBarcodeFormat, ScanzyBarcodeOptions} from 'react-native-scanzy-barcode-scanner-plugin';
//set lisense in your app init function
ScanzyBarcodeManager.setLicense('YOUR LICENSE KEY');
//set scan formats and options
const formats = [ScanzyBarcodeFormat.Code128, ScanzyBarcodeFormat.Code93, ScanzyBarcodeFormat.EAN13, ScanzyBarcodeFormat.QRCode];
const options: ScanzyBarcodeOptions = {
enableVibration: true,
enableBeep: true,
enableAutoZoom: false,
enableScanCropRectOnly: false,
formats: formats
}
// scan
ScanzyBarcodeManager.scan(options).then((result: ScanzyBarcodeScanResult)=>{
//get the scan result
console.log('Scan Result:', result.barcode, result.barcodeType)
})
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:
interface ScanzyBarcodeOptions {
enableVibration?: boolean;
enableBeep?: boolean;
enableAutoZoom?: boolean;
enableScanCropRectOnly?: boolean;
formats?: string[];
}
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.
The ScanzyBarcodeScanResult is defined as:
interface ScanzyBarcodeScanResult {
barcode: string;
barcodeType: string;
}
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!