A React-Native module which allows the use of native features (Ticket Printing, Opening Cash Drawer, ...) of a Pax Technology Android device through NeptuneLite API.
npm install react-native-pax-libraryA React-Native module which allows the use of native features (Ticket Printing, Opening Cash Drawer, ...) of a Pax Technology Android device through NeptuneLite API.
Follow carefully the steps below to use this library in your React-Native App
Install the package from npm
``sh`
npm install react-native-pax-library
Download the file libDeviceConfig.so
In your React-Native app, create a folder named jniLibs and place it inside _android/app/src/main_
Create a folder named armeabi-v7a inside _android/app/src/main/jniLibs_ and place the file libDeviceConfig.so there
Open _android/app/build.gradle_ and add the armeabi-v7a filter for the ndk in defaultConfig
``
...
android {
...
defaultConfig {
...
ndk {
abiFilters "armeabi-v7a"
}
}
}
Run your application
`sh`
npx react-native run-android
You can print a simple text using the method printStr(text:string, cutMode?:number):void
cutMode is an optional parameter to tell the printer how it should cut the paper (partially, fully or no cutting at all) after finishing printing.
If the parameter cutMode is not set then the printer will cut the paper fully.
Full Cut : Pax.FULL_CUT
Partial Cut : Pax.PARTIAL_CUT
No Cutting : Pax.NO_CUT
default: Pax.FULL_CUT
`js
import Pax from "react-native-pax-library";
// ...
Pax.printStr("Hello World", Pax.PARTIAL_CUT);
`
If you have a cash drawer linked to your Pax device, you will be able to open it automatically using the method openDrawer(): Promise
The result returned from this method is a promise that resolves with the result 0 if it succeeds.
`js
// ...
try {
const result = await Pax.openDrawer();
} catch (error) {
console.error("Unable to open Cash Drawer.");
}
``
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT