react-native-zebra-scanner
v1.0.0
Published
## Getting started
Downloads
21
Readme
react-native-zebra-scanner
Getting started
$ npm install react-native-zebra-scanner --save
Mostly automatic installation
$ react-native link react-native-zebra-scanner
Manual installation
Android
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
new ZebraScannerPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-zebra-scanner' project(':react-native-zebra-scanner').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-zebra-scanner/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:implementation project(':react-native-zebra-scanner')
Usage
import ZebraScanner from 'react-native-zebra-scanner';
// Check if hardware scanner is available
await ZebraScanner.isAvailable(); // true or false
// Add listener
const scanListener = (scannedCode) => {
// scannedCode is string. '01245234562345' etc.
}
ZebraScanner.addScanListener(scanListener)
// Remove listener
ZebraScanner.removeScanListener(scanListener)