react-native-usb
Getting started
npm install react-native-usb --save
or
yarn add react-native-usb
Mostly automatic installation
react-native link react-native-usb
Manual installation
Android
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import me.andyshea.ReactNativeUsbPackage;
to the imports at the top of the file - Add
new ReactNativeUsbPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-usb' project(':react-native-usb').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-usb/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-usb')
Usage
; // connect to deviceawait usb; // setup data event listenerusb; // send data to deviceusb; // disconnect when finishedusb;