react-native-chainway-datacollection
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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 -S

Usage

First you'll want to check whether the device is a Chainway scanner:

import ChainwayBarcodeReader from 'react-native-chainway-datacollection';

ChainwayBarcodeReader.isCompatible // true or false

The 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();

Package Sidebar

Install

npm i react-native-chainway-datacollection

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

2.94 MB

Total Files

18

Last publish

Collaborators

  • fuile