TSC printer module for React Native
npm install react-native-tsc-printer
Add the following to your AndroidManifest.xml
:
<!-- For Bluetooth connection -->
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
<!-- For USB connection -->
<uses-permission android:name="android.permission.USB_PERMISSION" />
<uses-feature android:name="android.hardware.usb.host" />
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
</intent-filter>
<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/device_filter" />
Add android/src/main/res/xml//device_filter.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<usb-device vendor-id="1203" />
</resources>
Add the following to your Info.plist
:
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Need bluetooth access for printing</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>Need bluetooth access for printing</string>
<key>UISupportedExternalAccessoryProtocols</key>
<array>
<string>com.issc.datapath</string>
</array>
The TSC USB functionality is conditionally compiled. You can enable it using one of the following methods:
Set the ENABLE_TSC_USB
environment variable to 1
before running pod install:
ENABLE_TSC_USB=1 pod install
Add the tscUsbEnabled
property to your project's root package.json
file:
{
"name": "your-app",
"version": "1.0.0",
"tscUsbEnabled": true
}
import Printer, { ConnectionType } from 'react-native-tsc-printer';
// ...
const printer = await Printer.connect(ConnectionType.USB, '1234567890');
await printer.addText(0, 0, 'Hello, world!');
await printer.print();
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
Made with create-react-native-library