1.3.4 • Published 3 years ago

react-native-uhf v1.3.4

Weekly downloads
118
License
-
Repository
-
Last release
3 years ago

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
  1. 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')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-uhf')

Example

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;
1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.2.0

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.1.2

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago