tr3v3r / react-native-esc-pos-printer

An unofficial React Native library for printing on an EPSON TM printer with the Epson ePOS SDK for iOS and Epson ePOS SDK for Android
MIT License
164 stars 71 forks source link

Printer unable to print after turning device screen off and back on or after switching apps #115

Closed vincentiusadityas closed 1 month ago

vincentiusadityas commented 1 year ago

Hi, I'm having an issue where I think the printer connection is lost after I turned my device's screen off and then back on. This also happens after switching between apps. After that, it was not able to print anything. I have to reconnect again (calling the instantiate function).

I'm using the instantiate function to enable printing simultaneously and using multiple printers.

Is there any way to keep the connection of the printer without having to instantiate the printer again?

Thank you!

Savan-ITDEV commented 1 year ago

I use Re-connect Instantiate again and it works for me

vincentiusadityas commented 12 months ago

I use Re-connect Instantiate again and it works for me

@Savan-ITDEV Could you please elaborate more or share the piece of code you use to do that? Thanks!

manage-some commented 9 months ago

Same issue

funkaarts commented 9 months ago

Yes I got the same issue. Were you able to solve it? Any help would be appreciated

@vincentiusadityas @Savan-ITDEV

This is what i'm doing to connect once app is launched


    await EscPosPrinter.instantiate({
        target: printer.target,
        seriesName,
        language: 'EPOS2_LANG_EN',
      });

      await EscPosPrinter.connect(printer.target);

The above code connects the printer and this code is used to print


  await EscPosPrinter.instantiate({
      target: printer.target,
      seriesName,
      language: 'EPOS2_LANG_EN',
    });

    await EscPosPrinter.connect(printer.target);

    const printing = new EscPosPrinter.printing();

    const receipt = epsonReceipt(printing, receiptEngineObj);
    if (printer.drawer_connected && isCashGiven) {
      receipt.addPulse('EPOS2_DRAWER_2PIN');
    }

    await receipt.send({
      target: printer.target,
    });
The whole process works smoothly but if network drops and reconnects or we switch between the apps the printer stops responding and the above code does not work.
The printer shows as connected though and only starts to work again if restart the app
Waleed065 commented 9 months ago

Facing the exact issue. Can anyone help me here?

@vincentiusadityas @Savan-ITDEV @funkaarts

Savan-ITDEV commented 8 months ago

my solution solution 1

Hope this solution help you guys thanks, guys ^^

On Sat, Jan 6, 2024 at 8:50 PM Waleed Tariq @.***> wrote:

Facing the exact issue. Can anyone help me here?

@vincentiusadityas https://github.com/vincentiusadityas @Savan-ITDEV https://github.com/Savan-ITDEV @funkaarts https://github.com/funkaarts

— Reply to this email directly, view it on GitHub https://github.com/tr3v3r/react-native-esc-pos-printer/issues/115#issuecomment-1879693498, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM6ZFYCSXL2FJMCXHXHL3HDYNFJDBAVCNFSM6AAAAAA3772BC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZZGY4TGNBZHA . You are receiving this because you were mentioned.Message ID: @.***>

Waleed065 commented 8 months ago

@Savan-ITDEV

But sometimes, i've notied that if internet turns off and then back on, The printer shows as connected but does not print. Similarly if print turns off and back on, it looses ability to print.

Any solution here?

Savan-ITDEV commented 8 months ago

Use this solution will help you,

solution 2

On Wed, 10 Jan 2024 at 11:19 PM Waleed Tariq @.***> wrote:

@Savan-ITDEV https://github.com/Savan-ITDEV

But sometimes, i've notied that if internet turns off and then back on, The printer shows as connected but does not print. Similarly if print turns off and back on, it looses ability to print.

Any solution here?

— Reply to this email directly, view it on GitHub https://github.com/tr3v3r/react-native-esc-pos-printer/issues/115#issuecomment-1885170992, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM6ZFYCC6BYL4WODSAWIJ6DYN25SFAVCNFSM6AAAAAA3772BC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBVGE3TAOJZGI . You are receiving this because you were mentioned.Message ID: @.***>

Waleed065 commented 8 months ago

Use this solution will help you, solution 2 - every print disconnects first and then reconnects and print is done ^^ EZ On Wed, 10 Jan 2024 at 11:19 PM Waleed Tariq @.> wrote: @Savan-ITDEV https://github.com/Savan-ITDEV But sometimes, i've notied that if internet turns off and then back on, The printer shows as connected but does not print. Similarly if print turns off and back on, it looses ability to print. Any solution here? — Reply to this email directly, view it on GitHub <#115 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM6ZFYCC6BYL4WODSAWIJ6DYN25SFAVCNFSM6AAAAAA3772BC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBVGE3TAOJZGI . You are receiving this because you were mentioned.Message ID: @.>

@Savan-ITDEV This can be a workaround but it's not a viable solution.

The android/ios SDK itself handles reconnectivity scenarios. It just needs to be added to this package as a built in feature

Savan-ITDEV commented 8 months ago

I suggest try my package : https://github.com/Savan-ITDEV/react-native-savanitdev-thermal-printer Hope will help you ^^ On Wed, 10 Jan 2024 at 11:26 PM Waleed Tariq @.***> wrote:

Use this solution will help you, solution 2 - every print disconnects first and then reconnects and print is done ^^ EZ … <#m6840549305437100080> On Wed, 10 Jan 2024 at 11:19 PM Waleed Tariq @.> wrote: @Savan-ITDEV https://github.com/Savan-ITDEV https://github.com/Savan-ITDEV https://github.com/Savan-ITDEV But sometimes, i've notied that if internet turns off and then back on, The printer shows as connected but does not print. Similarly if print turns off and back on, it looses ability to print. Any solution here? — Reply to this email directly, view it on GitHub <#115 (comment) https://github.com/tr3v3r/react-native-esc-pos-printer/issues/115#issuecomment-1885170992>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM6ZFYCC6BYL4WODSAWIJ6DYN25SFAVCNFSM6AAAAAA3772BC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBVGE3TAOJZGI https://github.com/notifications/unsubscribe-auth/AM6ZFYCC6BYL4WODSAWIJ6DYN25SFAVCNFSM6AAAAAA3772BC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBVGE3TAOJZGI . You are receiving this because you were mentioned.Message ID: @.>

@Savan-ITDEV https://github.com/Savan-ITDEV This can be a workaround but it's not a viable solution.

The android/ios SDK itself handles reconnectivity scenarios. It just needs to be added to this package as a built in feature

— Reply to this email directly, view it on GitHub https://github.com/tr3v3r/react-native-esc-pos-printer/issues/115#issuecomment-1885182504, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM6ZFYHCEGBCJKS5KJJBKH3YN26KPAVCNFSM6AAAAAA3772BC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBVGE4DENJQGQ . You are receiving this because you were mentioned.Message ID: @.***>

Waleed065 commented 8 months ago

I suggest try my package : https://github.com/Savan-ITDEV/react-native-savanitdev-thermal-printer Hope will help you ^^ On Wed, 10 Jan 2024 at 11:26 PM Waleed Tariq @.> wrote: Use this solution will help you, solution 2 - every print disconnects first and then reconnects and print is done ^^ EZ … <#m6840549305437100080> On Wed, 10 Jan 2024 at 11:19 PM Waleed Tariq @.> wrote: @Savan-ITDEV https://github.com/Savan-ITDEV https://github.com/Savan-ITDEV https://github.com/Savan-ITDEV But sometimes, i've notied that if internet turns off and then back on, The printer shows as connected but does not print. Similarly if print turns off and back on, it looses ability to print. Any solution here? — Reply to this email directly, view it on GitHub <#115 (comment) <#115 (comment)>>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM6ZFYCC6BYL4WODSAWIJ6DYN25SFAVCNFSM6AAAAAA3772BC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBVGE3TAOJZGI https://github.com/notifications/unsubscribe-auth/AM6ZFYCC6BYL4WODSAWIJ6DYN25SFAVCNFSM6AAAAAA3772BC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBVGE3TAOJZGI . You are receiving this because you were mentioned.Message ID: @.> @Savan-ITDEV https://github.com/Savan-ITDEV This can be a workaround but it's not a viable solution. The android/ios SDK itself handles reconnectivity scenarios. It just needs to be added to this package as a built in feature — Reply to this email directly, view it on GitHub <#115 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM6ZFYHCEGBCJKS5KJJBKH3YN26KPAVCNFSM6AAAAAA3772BC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBVGE4DENJQGQ . You are receiving this because you were mentioned.Message ID: @.>

Does this work with Epson Printers and both on IOS and Android?

tr3v3r commented 1 month ago

Should work with the latest version