Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetPrinter not working well for iOS #111

Open
ShinThantAein opened this issue Jan 9, 2024 · 0 comments
Open

NetPrinter not working well for iOS #111

ShinThantAein opened this issue Jan 9, 2024 · 0 comments

Comments

@ShinThantAein
Copy link

I'd like to print base64 image using printImageBase64() function. In Android, it's working well.
In iOS, successfully pod installed and build is successful. But when run on my device and call NetPrinter related functions, it's getting TCP Disconnected error continuously and app stopped after some time.

react : 18.2.0
react-native : 0.72
react-native-thermal-receipt-printer-image-qr : 0.1.11

111

import React, {useEffect} from 'react';
import {
SafeAreaView,
ScrollView,
View,
Text,
StatusBar,
} from 'react-native';
import {
NetPrinter,
NetPrinterEventEmitter,
RN_THERMAL_RECEIPT_PRINTER_EVENTS
} from 'react-native-thermal-receipt-printer-image-qr';

const App = () => {

useEffect(() => {
const initPrinterFunc = async () => {
NetPrinter.init().then(() => {
console.log("initialized Net printer...")
});
const results = await NetPrinter.getDeviceList();
console.log("results >> ", results);
};

initPrinterFunc();

}, []);

useEffect(() => {

NetPrinterEventEmitter.addListener(
  RN_THERMAL_RECEIPT_PRINTER_EVENTS.EVENT_NET_PRINTER_SCANNED_SUCCESS,
  (printers) => {
    console.log("Scanned >> ", printers);
    if (printers && printers.length > 0 && printers[0].host) {
      connectNetPrinter(printers[0].host);
    }
  },
);
(async () => {
    const results = await NetPrinter.getDeviceList();
    console.log("2 results >> ", results);
  })();

return () => {
NetPrinterEventEmitter.removeAllListeners(
RN_THERMAL_RECEIPT_PRINTER_EVENTS.EVENT_NET_PRINTER_SCANNED_SUCCESS,
);
NetPrinterEventEmitter.removeAllListeners(
RN_THERMAL_RECEIPT_PRINTER_EVENTS.EVENT_NET_PRINTER_SCANNED_ERROR,
);
};
}, []);

return (
<>




Hello World



</>
);
};

export default App;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant