0.3.1 • Published 10 days ago

@tillpos/rn-receipt-printer-utils v0.3.1

Weekly downloads
62
License
Apache-2.0
Repository
github
Last release
10 days ago

@tillpos/rn-receipt-printer-utils

Originally forked from react-native-thermal-receipt-printer

A React Native Library to connect to thermal printer over network and to send the buffer (data to be printed) to thermal printer.

Node.js Package

Installation

yarn add @tillpos/rn-receipt-printer-utils

Troubleshoot

  • when install in react-native version >= 0.60, xcode show this error
duplicate symbols for architecture x86_64

that because the .a library uses CocoaAsyncSocket library and Flipper uses it too

Podfile

...
  use_native_modules!

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  # add_flipper_pods!
  # post_install do |installer|
  #   flipper_post_install(installer)
  # end
...

and comment out code related to Flipper in ios/AppDelegate.m ios/AppDelegate.m

Support

PrinterAndroidIOS
USBPrinter:x::negative_squared_cross_mark:
BLEPrinter:heavy_check_mark::heavy_check_mark:
NetPrinter:heavy_check_mark::heavy_check_mark:

Tested on following platforms (manual)

PlatformFramework / libTested
AndroidReact Native:heavy_check_mark:
iOSReact Native:heavy_check_mark:

Development workflow

To get started with the project, run yarn bootstrap in the root directory to install the required dependencies for each package:

yarn bootstrap

While developing, you can run the example app to test your changes.

To start the packager:

yarn example start

To run the example app on Android:

yarn example android

To run the example app on iOS:

yarn example ios

To make build

yarn prepare

Usage

import {
  USBPrinter,
  NetPrinter,
  BLEPrinter,
} from "@tillpos/rn-receipt-printer-utils";

BLEPrinter.connectAndSend("xx-xx-xx-xx-xx", "<base64>", ()=>null, ()=>null);
NetPrinter.connectAndSend("xx-xx-xx-xx-xx", 9100, "<base64>", ()=>null, ()=>null);

Example

NetPrinter

interface INetPrinter {
  device_name: string;
  host: string;
  port: number;
  brand?: PrinterBrand;
}

Note: get list device for net printers is support scanning in local ip but not recommended

  const printer = {
    host: "192.168.10.24", 
    port: 9100,
    device_name: "Sample printer",
    brand: PrinterBrand.EPSON
  }
  _connectPrinter => () => {
    //connect printer
    await NetPrinter.connectAndSend(
      printer.host, 
      printer.port,
      (printer) => console.log("Printed"),
      error => console.warn(error)
    )
  }

  render() {
    return (
      <View style={styles.container}>
        {
            <TouchableOpacity onPress={(printer) => this._connectPrinter()}>
              {`device_name: ${printer.device_name}, host: ${printer.host}, port: ${printer.port}`}
            </TouchableOpacity>
            ))
        }
      </View>
    )
  }

  ...

TODO

  • Update documentation
  • Maintain Multiple connections
  • Use release-it to publish builds
  • Bluetooth support
  • USB support
0.3.1

10 days ago

0.3.0

11 days ago

0.2.19

1 year ago

0.2.18

1 year ago

0.2.17

1 year ago

0.2.16

1 year ago

0.2.15

1 year ago

0.2.14

1 year ago

0.2.13

1 year ago

0.2.11

1 year ago

0.2.10

1 year ago

0.2.6

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.1

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.0

2 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.18

3 years ago

0.0.17

3 years ago

0.0.16

3 years ago

0.0.15

3 years ago

0.0.13

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago