react-native-xprinter-thermal-ble
Version:
Portable xprinter native module for react-native
63 lines (50 loc) • 1.84 kB
Markdown
# react-native-xprinter-thermal
Portable xprinter sdk for react native android only
## Installation
```sh
yarn add react-native-xprinter-thermal-ble
```
Add service to ```AndroidManifest.xml```
```xml
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Add service below -->
<service android:name="net.posprinter.service.PosprinterService" >
</service>
<!-- End -->
</application>
```
## Usage
```ts
import { XprinterThermal } from "react-native-xprinter-thermal-ble";
// ...
// Interface for xprinter module
interface IXprinterThermal {
isConnected: () => Promise<boolean>;
rebindService: () => Promise<any>;
connectNet: (ip: string, port: number) => Promise<void>;
connectBle: (bleAddress: string) => Promise<void>;
disconnect: () => Promise<void>;
addEmptyLine: () => void;
addText: (content: string) => void;
addBarcode: (content: string, width?: number, height?: number) => void;
addQRcode: (content: string, width?: number) => void;
print: () => Promise<string>;
}
```
## Contributing
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
## License
MIT
---
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)