Caution: this is not the official project and forked form https://github.com/januslo/react-native-sunmi-inner-printer
Offical Demos refer: https://github.com/shangmisunmi/SunmiPrinterDemo
Step 1.
Install via NPM
npm install react-native-sunmi-v2-printer --save
Install via Yarn
yarn add react-native-sunmi-v2-printer
Install from source
npm install https://github.com/suraneti/react-native-sunmi-v2-printer.git --save
yarn add https://github.com/suraneti/react-native-sunmi-v2-printer.git --save
Step 2: (For React-Native < 0.60)
Links this plugin to your project.
react-native link react-native-sunmi-v2-printer
or you may need to link manually
- modify settings.gradle
include ':react-native-sunmi-v2-printer'
project(':react-native-sunmi-v2-printer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sunmi-v2-printer/android')
- modify app/build.gradle,add dependenceie:
compile project(':react-native-sunmi-v2-printer')
- adds package references to MainPackage.java
import com.sunmi.v2.printer.SunmiV2PrinterPackage;
...
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new SunmiV2PrinterPackage()
);
}
Step 3:
Import in React-Native:
import SunmiV2Printer from 'react-native-sunmi-v2-printer';
Name | Type | Description |
---|---|---|
Constants | string | Printer's status |
hasPrinter | boolean | Is printer available |
printerVersion | string | Printer's version |
printerSerialNo | string | Printer's serial number |
printerModal | string | Printer's model |
Name | Description |
---|---|
OUT_OF_PAPER_ACTION | Printer of paper |
ERROR_ACTION | Printing error |
NORMAL_ACTION | Printing normal |
COVER_OPEN_ACTION | Printer's cover has open |
COVER_ERROR_ACTION | Printer's cover is unusal |
KNIFE_ERROR_1_ACTION | 切刀异常1-卡切刀 |
KNIFE_ERROR_2_ACTION | 切刀异常2-切刀修复 |
OVER_HEATING_ACITON | Printer is overheat |
FIRMWARE_UPDATING_ACITON | Upgrade printer's firmware |
Please check on example/
floder