npm install react-native-esc-pos-printer
or
yarn add react-native-esc-pos-printer
Add the following permissions to android/app/src/main/AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"
android:usesPermissionFlags="neverForLocation"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<!-- Request legacy permissions on older devices. -->
<uses-permission android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"
android:maxSdkVersion="30"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"
android:maxSdkVersion="28"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="18"/>
See explanation of permissions here
pod install
For iOS13 or later, add Privacy-Bluetooth Always Usage Description.
- In Project Navigator, select *.plist. (The file name will be Project name-info.)
- In the pop-up menu, select Add Row.
- Select "Privacy-Bluetooth Always Usage Description".
- Enter the intended use of Bluetooth in the "Value" field. (Example: Use this to communicate with the printer.)
When the Bluetooth or USB is used, set the protocol name. Set the protocol name according to the following procedure:
- In Project Navigator, select *.plist. (The file name will be Project name-info.)
- In the pop-up menu, select Add Row.
- Select "Supported external accessory protocols".
- Expand the items added in Step 3.
- Enter com.epson.escpos as the Value for Item 0.
npx expo install react-native-esc-pos-printer
npx expo prebuild
Modify app.json
:
{
"android": {
"permissions": [
"android.permission.INTERNET",
"android.permission.BLUETOOTH_SCAN",
"android.permission.BLUETOOTH_CONNECT",
"android.permission.BLUETOOTH",
"android.permission.BLUETOOTH_ADMIN",
"android.permission.ACCESS_FINE_LOCATION",
"android.permission.ACCESS_COARSE_LOCATION",
"android.permission.WRITE_EXTERNAL_STORAGE",
"android.permission.READ_EXTERNAL_STORAGE"
]
}
}
See explanation of permissions here
{
"ios": {
"infoPlist": {
"NSBluetoothAlwaysUsageDescription": "Use this to communicate with the printer.",
"UISupportedExternalAccessoryProtocols": ["com.epson.escpos"]
}
}
}