# react-native-uhf

> ## Getting started

Latest version **1.3.4** (published 2021-01-27) · 0 weekly downloads

## Install

```sh
npm install react-native-uhf
pnpm add react-native-uhf
yarn add react-native-uhf
bun add react-native-uhf
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.4 |
| Published | 2021-01-27 |
| First published | 2020-12-13 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | honcao95 |
| Keywords | react-native-uhf |

## Links

- npm: https://www.npmjs.com/package/react-native-uhf
- npm.io page: https://npm.io/package/react-native-uhf

## Recent versions

- 1.3.4 (latest) — 2021-01-27
- 1.3.3 — 2021-01-24
- 1.3.2 — 2021-01-23
- 1.3.1 — 2021-01-23
- 1.2.2 — 2020-12-29
- 1.2.1 — 2020-12-29
- 1.2.0 — 2020-12-29
- 1.1.4 — 2020-12-29
- 1.1.3 — 2020-12-16
- 1.1.2 — 2020-12-15
- 1.1.1 — 2020-12-15
- 1.1.0 — 2020-12-15
- 1.0.7 — 2020-12-14
- 1.0.6 — 2020-12-14
- 1.0.5 — 2020-12-14
- … 5 more at https://npm.io/package/react-native-uhf/versions

## README

# react-native-uhf

## Getting started

`$ npm install react-native-uhf --save`

### Mostly automatic installation

`$ react-native link react-native-uhf`

### Manual installation


#### Android

1. Open up `android/app/src/main/java/[...]/MainActivity.java`
  - Add `import com.reactlibrary.RNReactNativeUhfPackage;` to the imports at the top of the file
  - Add `new RNReactNativeUhfPackage()` to the list returned by the `getPackages()` method
2. Append the following lines to `android/settings.gradle`:
  	```
  	include ':react-native-uhf'
  	project(':react-native-uhf').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-uhf/android')
  	```
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
  	```
      compile project(':react-native-uhf')
  	```

## Example
```javascript
import React, {Component} from 'react';
import {
  DeviceEventEmitter,
  PermissionsAndroid,
  ScrollView,
  View,
  Text,
  StatusBar,
  Button,
  Alert,
} from 'react-native';

import RNReactNativeUhf from 'react-native-uhf';

class App extends Component {

  componentDidMount() {
    this.startUhfListener();
  }

  startUhfListener() {
    RNReactNativeUhf.startUhfService();

    DeviceEventEmitter.addListener(
      'onReadDataScanner',
      this.onReadDataScanner,
      this
    );
    DeviceEventEmitter.addListener(
      'onReadDataConnect',
      this.onReadDataConnect,
      this
    );
    DeviceEventEmitter.addListener(
      'onReadDataInventory',
      this.onReadDataInventory,
      this
    );
  }

  onReadDataScanner(data) {
    console.log('onReadDataScanner', data);
  }

  onReadDataConnect(data) {
    console.log('onReadDataConnect', data);
  }

  onReadDataInventory(data) {
    console.log('onReadDataInventory', data);
  }

  showBluetoothDevice() {
    RNReactNativeUhf.showBluetoothDevice();
  }

  connect() {
    RNReactNativeUhf.connect("C0:44:82:B6:20:6E");
  }

  disconnect() {
    RNReactNativeUhf.disconnect();
  }

  inventory() {
    RNReactNativeUhf.getInventory();
  }

  inventoryLoop() {
    RNReactNativeUhf.getInventoryLoop();
  }

  inventoryLoopStop() {
    RNReactNativeUhf.stopInventoryLoop();
  }

  clearInventory() {
    RNReactNativeUhf.clearInventory();
  }

  setScanned() {
    RNReactNativeUhf.setInventory(true);
  }

  render() {
    return (
      <View>
        <Button onPress={this.showBluetoothDevice} title="showBluetoothDevice" />
        <Button onPress={this.connect} title="connect" />
        <Button onPress={this.disconnect} title="disconnect" />
        <Button onPress={this.inventory} title="inventory" />
        <Button onPress={this.inventoryLoop} title="inventoryLoop" />
        <Button onPress={this.inventoryLoopStop} title="inventoryLoopStop" />
        <Button onPress={this.clearInventory} title="clearInventory" />
        <Button onPress={this.setScanned} title="setScanned" />
      </View>
    );
  }
}

export default App;

```

---
_Source: https://npm.io/package/react-native-uhf · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
