library for pos printer on react native
npm install react-native-pos-printerreact native module for printing receipt on pos printer.
For now it's only support for android
1. RNFetchBlob (optional) if you want to print with image
$ npm install react-native-pos-printer --save
$ react-native link react-native-pos-printer
#### iOS
Still not supported yet
#### Android
1. Open up android/app/src/main/java/[...]/MainActivity.java
- Add import com.reactlibrary.RNPosPrinterPackage; to the imports at the top of the file
- Add new RNPosPrinterPackage() to the list returned by the getPackages() method
2. Append the following lines to android/settings.gradle:
```
include ':react-native-pos-printer'
project(':react-native-pos-printer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-pos-printer/android')
android/app/build.gradle
3. Insert the following lines inside the dependencies block in :`
`
compile project(':react-native-pos-printer')
javascript
import RNPosPrinter from 'react-native-pos-printer';
`$3
For the first time need to initialize the pos printer, the return will be Promise
`javascript
RNPosPrinter.init(true);
`
#### Option
`javascript
isDebug: boolean //default false
`$3
To get all printer devices you just need to call this one, the return will be Promise
`javascript
RNPosPrinter.getDevices()
`
$3
To scan all devices printer, the return will be Promise
`javascript
RNPosPrinter.scanDevices(callback);
`
#### Option
`javascript
callback: Callback
`$3
To stop scanning all devices printer, the return will be Promise
`javascript
RNPosPrinter.stopScanDevices();
`$3
To connect to specific pos printer, the return will be Promise
`javascript
RNPosPrinter.connectDevice(deviceId, timeout);
`
#### Option
`javascript
deviceId: string
timeout: number //default 30000 ms
`$3
To connect and automatically print on specific pos printer, the return will be Promise
`javascript
RNPosPrinter.connectAndPrintReceipt(deviceId);
`
#### Option
`javascript
deviceId: string
`$3
To print on pos printer
`javascript
RNPosPrinter.printTestReceipt(storageUrl);
`
#### Option
`javascript
storageUrl: string //optional, if want to print image
`$3
If you want to use directly the printer command you can access on
`javascript
RNPosPrinter.printerModule
``