Skip to content

iliapnmrv/react-native-urovo

Repository files navigation

react-native-urovo

React native bindings for urovo scanners

  • Works on both old Legacy Native Modules and new Turbo Native Modules architectures
  • Uses latest urovo SDK
  • Supports latest React Native version v0.77+

Compatibility

This library tries to support as many RN versions as possible. For now the goal is to support the same versions as RN itself, you can learn more here

RN-urovo version RN version Supports New Architecture
1.0.0 0.77 yes
1.0.0 0.76 yes
1.0.0 0.75 no
1.0.0 0.74 no

versions <= 0.73 are not supported

Installation

npm install react-native-urovo

Usage

First, you have to open/init the scanner

import { closeScanner, openScanner } from 'react-native-urovo';

useEffect(() => {
  openScanner();

  return () => {
    // make sure to close scanner to avoid unexpected behaviour
    closeScanner();
  };
}, []);

Then, add listener on module, UROVO_EVENTS.ON_SCAN event type

import Urovo, { type ScanResult, UROVO_EVENTS } from 'react-native-urovo';

useEffect(() => {
  let eventListener: EmitterSubscription | undefined;
  if (Urovo) {
    // used only for type safety
    const eventEmitter = new NativeEventEmitter(Urovo);
    eventListener = eventEmitter.addListener(
      UROVO_EVENTS.ON_SCAN,
      (scan: ScanResult) => {}
    );
  }

  return () => {
    eventListener?.remove();
  };
}, []);

Types

type ScanResult = {
  value: string;
  type: number;
};

Contributing

If you have any feature requests, feel free ask for it

License

MIT