react-native-suno-sunmi-printer
v1.0.3
Published
test
Downloads
5
Readme
react-native-suno-sunmi-printer
React Native Suno Sunmi Printer
Installation
npm install react-native-suno-sunmi-printer
Usage
import { SunmiPrinter, SunmiPrinterStatus } from 'react-native-suno-sunmi-printer';
// ...
const print = async () => {
if (Platform.OS === 'android') {
const grantedWriteStorage: PermissionStatus =
await PermissionsAndroid.request(
'android.permission.WRITE_EXTERNAL_STORAGE',
{
title: 'Yêu cầu quyền ghi dữ liệu',
message:
'Cho phép ứng dụng Suno truy xuất ghi dữ liệu để in hóa đơn?',
buttonNegative: 'Đóng',
buttonPositive: 'Đồng ý',
}
);
const grantedReadStorage: PermissionStatus =
await PermissionsAndroid.request(
'android.permission.READ_EXTERNAL_STORAGE',
{
title: 'Yêu cầu quyền đọc dữ liệu',
message:
'Cho phép ứng dụng Suno truy xuất đọc dữ liệu để in hóa đơn?',
buttonNegative: 'Đóng',
buttonPositive: 'Đồng ý',
}
);
if (
grantedReadStorage === 'granted' &&
grantedWriteStorage === 'granted'
) {
try {
const printer = new SunmiPrinter();
if (SunmiPrinterStatus.hasPaper && !SunmiPrinterStatus.coverOpen) {
await printer.setAlignment(0);
await printer.printString('Print text, print text, print text !!!');
await printer.printOriginalText('\n');
await printer.lineWrap(1);
await printer.cutPaper();
}
} catch (e) {
console.log('Print error =>', e);
}
}
}
};
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT
Made with create-react-native-library