1.0.5 • Published 5 months ago

react-native-zepra-scanner-1 v1.0.5

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

react-native-zippra-scanner

Zebra scanner for react native ("https://www.zebra.com/us/en/support-downloads/software/developer-tools/scanner-sdk-for-android.html")

Installation

npm react-native-zepra-scanner-1

npx expo install react-native-zepra-scanner-1

Usage

import * as React from 'react';

import {
  StyleSheet,
  View,
  Button,
  DeviceEventEmitter,
  Text,
} from 'react-native';
import {
  findCabledScanner,
  findBluetoothScanner,
  requestBluethoothAccess,
  setupApi,
  getActiveScannersList,
  Listeners,
} from 'react-native-zepra-scanner-1';

export default function App() {
  const [code, setCode] = React.useState('');

  React.useEffect(() => {
    requestBluethoothAccess().then(setupApi);

    DeviceEventEmitter.addListener(Listeners.SCANNER_DISAPPEARED, () =>
      console.log('SCANNER_DISAPPEARED')
    );
    DeviceEventEmitter.addListener(Listeners.SCANNER_ESTABLISHED, () =>
      console.log('SCANNER_ESTABLISHED')
    );
    DeviceEventEmitter.addListener(Listeners.SESSION_TERMINATED, () =>
      console.log('SESSION_TERMINATED')
    );
    DeviceEventEmitter.addListener(
      Listeners.BARCODE_RECEIVED,
      (value: string) => setCode(value)
    );
  }, []);

  const getDevices = () => {
    getActiveScannersList().then((devices) => {
      console.log(JSON.stringify(devices));
    });
  };

  return (
    <View style={styles.container}>
      <Text>Result: {code}</Text>
      <Button
        style={styles.openButton}
        onPress={() => findBluetoothScanner('A4:C7:4B:3B:38:F5')}
        title={'Open bluetooth barcode'}
      />
      <Button
        style={styles.openButton}
        onPress={findCabledScanner}
        title={'Open usb barcode'}
      />
      <Button
        style={styles.openButton}
        onPress={getDevices}
        title={'Get Devices'}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'space-around',
  },
  openButton: {
    width: 120,
    height: 60,
    backgroundColor: '#000000',
  },
});

Contributing

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

License

MIT


Made with create-react-native-library

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago