-
Notifications
You must be signed in to change notification settings - Fork 106
Open
Description
@thiendangit
I have problem printing Bluetooth with IOS but printing normally with Android with the code below.
const handlePrintTestBLE = async item => {
try {
await BLEPrinter.init();
await BLEPrinter.connectPrinter(item?.ipAddress);
showMessage({message: 'Đang in hóa đơn!', type: 'info'});
await BLEPrinter.printImageBase64(printDemo, {
imageWidth: item.paper.value ? Number(item.paper.value) : 576,
imageHeight: item.paper.value ? Number(item.paper.value) * 0.8 : 460,
});
if (item.paper.value == '576') {
if (IS_ANDROID) {
await BLEPrinter.printBill('');
// await new Promise(resolve => setTimeout(resolve, 500)); // 500ms delay
// await BLEPrinter.printBill('\x1d\x56\x00'); // Cut paper
} else {
BLEPrinter.printBill('');
}
}
await BLEPrinter.closeConn();
} catch (error) {
const errorMessage = error?.message || error?.toString?.() || '';
if (
errorMessage.includes(
'Can not find the specified printing device, please perform Bluetooth pairing in the system settings first.',
)
) {
setModalType('warningBLT');
setNotiModalVisible(true);
} else {
showMessage({
message: 'Không kết nối được với máy in này!',
type: 'info',
});
}
}
};When running on real IOS device, it shows error like this
API MISUSE: <CBCentralManager: 0x139ea3300> can only accept this command while in the powered on state
I tried wrapping the BLEPrinter.connectPrinter function in the getDeviceList callback and it gives an error.
Can\'t connect to printer + UUID
Can anyone give me a sample code to successfully connect and print photos using BLEPrinter on IOS 🫶
Metadata
Metadata
Assignees
Labels
No labels