0.1.15 • Published 5 months ago

react-native-chainway-c71 v0.1.15

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

react-native-chainway-c71

React native wrapper for the chainway sdk

Installation

npm install react-native-chainway-c71

Usage

import ChainwayC71 from "react-native-chainway-c71";
// ...

const BarcodeScannerScreen: React.FC = () => {
  const [idNumber, setIdNumber] = useState("")
  useEffect(() => {
    const handleBarcodeScan = (data: any) => {
      setIdNumber(data.replace(/[^a-zA-Z0-9]/g, '').substring(0, 16));
    };
    ChainwayC72Component.initReader();

    // Add a listener for barcode scanning
    ChainwayC72Component.addBarcodeListener(handleBarcodeScan);

    // Clean up the listener when the component unmounts
    return () => {
      ChainwayC72Component.removeBarcodeListener(handleBarcodeScan);
      ChainwayC72Component.deinitReader();
    };
  }, []);

  const startBarcodeScan = async () => {
    try {
      if (await ChainwayC72Component.startBarcodeScan()) {
        console.log('Barcode scanning started');
      } else {
        throw new Error('');
      }
    } catch (error) {
      console.error('Error starting barcode scanning:', error);
    }
  };

  return (
    <View>
      <Text style={{marginVertical: 20}}>
        Barcode Scanner{idNumber && `: ${idNumber}`}
      </Text>
      <Button title="Start Scan" onPress={startBarcodeScan} />
    </View>
  );
};

export default BarcodeScannerScreen;

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

0.1.11

5 months ago

0.1.12

5 months ago

0.1.13

5 months ago

0.1.14

5 months ago

0.1.15

5 months ago

0.1.10

8 months ago

0.1.9

9 months ago

0.1.8

9 months ago

0.1.7

9 months ago

0.1.6

9 months ago

0.1.5

9 months ago

0.1.4

9 months ago

0.1.3

9 months ago

0.1.2

9 months ago

0.1.1

9 months ago

0.1.0

9 months ago