1.0.1 • Published 2 years ago
react-native-chainway-datacollection v1.0.1
React Native Chainway Barcode Reader for data collection
This package works with Chainway devices that have an integrated barcode scanner, like the Chainway 2ds (tested).
Installation
npm i react-native-chainway-datacollection -SUsage
First you'll want to check whether the device is a Chainway scanner:
import ChainwayBarcodeReader from 'react-native-chainway-datacollection';
ChainwayBarcodeReader.isCompatible // true or falseThe barcode reader needs to be "claimed" by your application; meanwhile no other application can use it. You can do that like this:
ChainwayBarcodeReader.register().then((claimed) => {
console.log(claimed ? 'Barcode reader is claimed' : 'Barcode reader is busy');
});Enable automation the barcode scanner:
ChainwayBarcodeReader.automatic()To get events from the barcode scanner:
ChainwayBarcodeReader.onBarcodeReadSuccess(event => {
console.log('Received data', event);
});
ChainwayBarcodeReader.onBarcodeReadFail(() => {
console.log('Barcode read failed');
});To free the claim and stop the reader, also freeing up resources:
ChainwayBarcodeReader.unRegister().then(() => {
console.log('Freedom!');
});To stop receiving events:
ChainwayBarcodeReader.offBarcodeReadSuccess();
ChainwayBarcodeReader.offBarcodeReadFail();