0.0.1 • Published 1 year ago

react-native-pax-library-pos v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

react-native-pax-library-pos

This native module allows the use of native features (Ticket Printing, Opening Cash Drawer, ...) of a Pax Technology Android device through NeptuneLite API.

STILL UNDER DEVELOPMENT

ANDROID ONLY

Installation

Follow carefully the steps below to use this library in your React-Native App

Step 1

Install the package from npm

npm install react-native-pax-library-pos

Step 2

Download the file libDeviceConfig.so

Step 3

In your React-Native app, create a folder named jniLibs and place it inside android/app/src/main

Step 4

Create a folder named armeabi-v7a inside android/app/src/main/jniLibs and place the file libDeviceConfig.so there

Step 5

Open android/app/build.gradle and add the armeabi-v7a filter for the ndk in defaultConfig

...
android {
    ...
    defaultConfig {
        ...
        ndk {
            abiFilters "armeabi-v7a"
        }
    }
}

Step 6

Run your application

npx react-native run-android

Usage

Printing

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

import Pax from "react-native-pax-library-pos";

// ...

Pax.printStr("Hello World", Pax.PARTIAL_CUT);

Opening Cash Drawer

If you have a cash drawer linked to your Pax device, you will be able to open it automatically using the method openDrawer(): Promise<any>

The result returned from this method is a promise that resolves with the result 0 if it succeeds.

// ...

try {
  const result = await Pax.openDrawer();
} catch (error) {
  console.error("Unable to open Cash Drawer.");
}

🤝 Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page. The code is short, throughly commented and well tested, so you should feel quite comfortable working on it.

  • If you have any doubt or suggestion, please open an issue or contact me via email (huzaifajunaid.hazel@gmail.com)

License

MIT