januslo / react-native-bluetooth-escpos-printer

React-Native plugin for the bluetooth ESC/POS & TSC printers.
MIT License
359 stars 419 forks source link

Not working on iOS, can not connect with the device on iOS! #16

Open shivanshrajpoot opened 5 years ago

shivanshrajpoot commented 5 years ago

I have been trying to connect it an Epson Thermal Printer, the library works awesome with the android app, but I am not able to make it work with the iOS device.

januslo commented 5 years ago

May I know what is problem?

发自我的 iPhone

在 2019年1月2日,下午12:10,Shivansh Rajpoot notifications@github.com 写道:

I have been trying to connect it an Epson Thermal Printer, the library works awesome with the android app, but I am not able to make it work with the iOS device.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

shivanshrajpoot commented 5 years ago

When I try to scan it lists a lot of devices with UNKNOWN name, so can not find which one is mine, even when I try to connect it with correct device, I am not able to print with it. Could you please share a working code repo as the examples in this repo are not building in my Xcode, showing multiple header file issues. Xcode Version 10.1 (10B61) Target iOS: 12.1(16B92)

januslo commented 5 years ago

You need to check the device address

发自我的 iPhone

在 2019年1月2日,下午2:23,Shivansh Rajpoot notifications@github.com 写道:

When I try to scan it lists a lot of devices with UNKNOWN name, so can not find which one is mine, even when I try to connect it with correct device, I am not able to print with it.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

shivanshrajpoot commented 5 years ago

What device address are you referring to? Could please help me out running it on iOS?

januslo commented 5 years ago

Em.... unknown device name because no name provided from the device, actually I don’t know the reason in detail. Have you got any idea? Or can you provide more about the device you are working with?

发自我的 iPhone

在 2019年1月2日,下午3:44,Shivansh Rajpoot notifications@github.com 写道:

What device address are you referring to? Could please help me out running it on iOS?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

shivanshrajpoot commented 5 years ago

I'm using an Epson TM-P20 Direct Thermal Printer - Monochrome - which is listed with proper name and pairing with the app on android, but on iOS everything breaks and example app does not even build for iOS on Xcode, can you check why is it not building on iOS?

januslo commented 5 years ago

I can build , what build issue your facing?

发自我的 iPhone

在 2019年1月2日,下午11:35,Shivansh Rajpoot notifications@github.com 写道:

I'm using an Epson TM-P20 Direct Thermal Printer - Monochrome - which is listed with proper name and pairing with the app on android, but on iOS everything breaks and example app does not even build for iOS on Xcode, can you check why is it not building on iOS?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

shivanshrajpoot commented 5 years ago

When I try ti build the example on Xcode it shows 'React/RCTBundleURLProvider.h' file not found', when i google for this error, and follow the instructions, new header file errors come up, could not find why is this happening? In the scheme for Build it lists three dependencies :-

  1. React(missing)
  2. bluetoothEscposPrinterExamples
  3. examplesTest(missing).

Please provide an updated example if possible with latest ReactNative Version.

shivanshrajpoot commented 5 years ago

Upgraded the example to latest version using react-native-git-upgrade, stuck on 'RCTSubtractionAnimatedNode.h' file not found'.

januslo commented 5 years ago

That should not be the problem of this plugin, plz double check the upgrade guide of RN.

发自我的 iPhone

在 2019年1月3日,下午1:02,Shivansh Rajpoot notifications@github.com 写道:

Upgraded the example to latest version using react-native-git-upgrade, stuck on 'RCTSubtractionAnimatedNode.h' file not found'.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

shivanshrajpoot commented 5 years ago

Please update the example for the latest version. Also when I am using the code on a new RN project it does not connect at all, the app crashes when I tap on any row in the list!

Also I'm getting warnings : RNBluetoothEscposPrinter requires main queue setup since it overrides contantsToExport but doesn't implement requiresMainQueueSetup.

shivanshrajpoot commented 5 years ago

@januslo are you able to help me out with this as I'm not able to connect with the printer on iOS? Are you able to see device's BT address on iOS as it lists only UUIDs on the iOS! DEVICE_FOUND_EVENT only returns

{
device: 
             {
                 address: "9DA2BF7F-1C4F-6B54-4297-C758C945B7E2"
                 name: "LSBand2"
             }
}

Also can you provide filtering only for specific uuid characteristics while searching?

januslo commented 5 years ago

"filtering only for specific uuid characteristics while searching" would return nothing, i have tried that before.

januslo commented 5 years ago

RNBluetoothEscposPrinter requires main queue setup since it overrides contantsToExport but doesn't implement requiresMainQueueSetup. this should be a problem, will fix it as long as i got time to it.

shivanshrajpoot commented 5 years ago

RNBluetoothEscposPrinter requires main queue setup since it overrides contantsToExport but doesn't implement requiresMainQueueSetup. this should be a problem, will fix it as long as i got time to it.

App crashes every time I try to connect with any device listed.

januslo commented 5 years ago

@januslo are you able to help me out with this as I'm not able to connect with the printer on iOS? Are you able to see device's BT address on iOS as it lists only UUIDs on the iOS! DEVICE_FOUND_EVENT only returns

{
device: 
             {
                 address: "9DA2BF7F-1C4F-6B54-4297-C758C945B7E2"
                 name: "LSBand2"
             }
}

Also can you provide filtering only for specific uuid characteristics while searching?

Sorry? what is BT address? I see the UUIDs would be the same thing of the BT address, am i right? Hmmm... I am using that UUID to connect the device and success, what's the problem you meat ? I don't really know what are you talking about actually.

shivanshrajpoot commented 5 years ago

@januslo are you able to help me out with this as I'm not able to connect with the printer on iOS? Are you able to see device's BT address on iOS as it lists only UUIDs on the iOS! DEVICE_FOUND_EVENT only returns

{
device: 
             {
                 address: "9DA2BF7F-1C4F-6B54-4297-C758C945B7E2"
                 name: "LSBand2"
             }
}

Also can you provide filtering only for specific uuid characteristics while searching?

Sorry? what is BT address? I see the UUIDs would be the same thing of the BT address, am i right? Hmmm... I am using that UUID to connect the device and success, what's the problem you meat ? I don't really know what are you talking about actually.

Actually whenever I try to connect with a device, the app crashes, and by BT address I mean Bluetooth's mac BT:00:01:90:C2:A9:8F.

januslo commented 5 years ago

it perfectly work with my device , I can see the name, the uuids as address, connect and print normally , so if crash, plz show me you crash report so that i can do more test img

shivanshrajpoot commented 5 years ago

it perfectly work with my device , I can see the name, the uuids as address, connect and print normally , so if crash, plz show me you crash report so that i can do more test img

Okay let me just create a crash report for you.

shivanshrajpoot commented 5 years ago

Could you specify which version of Xcode and iOS are you using? Also the build system on the Xcode? As I notice from above screenshot its different code than used in the example, could you please provide the code you are using in your app, as there

The app crashes after this: 2019-01-04 16:28:44.038524+0530 FreshPrint[1627:195350] Trying to connect....EEAB2C71-87BC-5478-F78E-33CF8C0FD65C

After that the whole lists just shows UNKNOWN, and at the end found.push is not a function.

Are you able to connect to the bluetooth device within from the app? I'm trying to pair it from the settings then expecting it to be in the list of paired devices in the app.

Could you please explain how did you manage to print receipt on iOS? Like from the scratch which steps did you follow?

I successfully built the example using Legacy Build System in the Xcode, the example app crashes on clicking on the any on the available devices.

If possible could you please send me your latest demo project for Testing on my device.

januslo commented 5 years ago

I have update my iOS code and demo (the part of scan function),you may have a check. For the building issue, using legacy build would be my choice since we just update to Xcode 10 and still lots things to be adjusted for that. For the UNKNOWN name issue, you may have a check about here: https://stackoverflow.com/questions/45908137/corebluetooth-to-fetch-device-names-using-swift I really don't know whether need to filter those empty data currently, or you may do that in your js code. Besides, I have add a NSTimer to stop scanning to prevent scan executes infinity.

shivanshrajpoot commented 5 years ago

Thanks for the update!! Really appreciate your help! Will update yoi after testing and will close the issue asap!

januslo commented 5 years ago

besides , here is a part of package.json of the project i am woking with, you can see i am working with RN 0.57.1, in the other hand, I have tested with 0.57.8 as well:

 "dependencies": {
    "@januslo/react-native-wechat": "git+https://github.com/januslo/react-native-wechat.git",
    "mtils": "^2.0.3",
    "react": "^16.3.1",
    "react-native": "^0.57.1",
    "react-native-bluetooth-escpos-printer": "0.0.4",
    "react-native-camera": "^1.2.0",
    "react-native-check-box": "^2.1.3",
    "react-native-deprecated-custom-components": "^0.1.2",
    "react-native-fs": "^2.11.17",
    "react-native-image-picker": "^0.27.2",
    "react-native-local-barcode-recognizer": "0.0.2",
    "react-native-permissions": "^1.1.1",
    "react-native-picker": "^4.3.7",
    "react-native-qrcode-svg": "^5.1.1",
    "react-native-render-html": "^3.10.0",
    "react-native-splash-screen": "^3.1.0",
    "react-native-svg": "^6.5.2",
    "react-native-svg-charts": "^5.2.0",
    "react-native-swiper": "^1.5.13",
    "react-native-tab-navigator": "^0.3.4",
    "react-native-view-shot": "^2.5.0",
    "react-transform-hmr": "^1.0.4"
  },
  "devDependencies": {
    "babel-core": "6.26.3",
    "babel-jest": "23.4.2",
    "babel-preset-react-native": "4.0.0",
    "jest": "23.5.0",
    "react-devtools": "^3.3.3",
    "react-test-renderer": "16.0.0-alpha.6",
    "schedule": "^0.4.0"
  },
shivanshrajpoot commented 5 years ago

I have tested it with the Epson Bluetooth Printer TM-P20 Series Mobile Printer, Its not being listed in the device, I have downloaded and ran a sample project provided by the Epson along with the SDK, it allows to filter devices and print immediately, but the problem is, I am not a native developer and don't have enough knowledge to create a bridge for the SDK. Could you please help me out with this? Here is the link I used for iOS SDK: https://download.epson-biz.com/modules/pos/index.php?page=single_soft&cid=5978&scat=58&pcat=3

januslo commented 5 years ago

hmmmmm.... actually , YOU can just start a RN plugin project for that, it's not a complex job .

FazilMuhammed commented 5 years ago

@januslo I using react-native 0.52.0 printer- Mini termal printer ESC-POS function to print.

"react-native-bluetooth-escpos-printer" = "0.0.5"

I m getting stuck couple of weeks to print data in iOS. bluetooth scaning and pairing everything working perfectly.

after pairing success printText("Hello World") function. printer not responding(Printer mode is ON, No other devices is connected).

Code

      BluetoothManager.connect(9DA2BF7F-1C4F-6B54-4297-C758C945B7E2)
              .then((s) => {
                this.setState({
                  loading:false,
                  boundAddress:row.address,
                  name:row.name || "UNKNOWN"
              }, async () => {

                 await  BluetoothEscposPrinter.printText("Hello World\n\r",{
                     encoding:'GBK',
                     codepage:0,
                     widthtimes:3,
                     heigthtimes:3,
                     fonttype:1
                });

                     } )
              },(e)=>{
                  this.setState({
                      loading:false
                  })
                  alert(e);
              })

Help Me...!!

livingmine commented 4 years ago

@FazilMuhammed @januslo somehow if you use the following code in iOS, then things are not working. So I have to remove it and things are working just fine.


await BluetoothEscposPrinter.printText(
    'Some Text',
    {// This parameter breaks iOS
      encoding: 'GBK',
      codepage: 0,
      widthtimes: 3,
      heigthtimes: 3,
      fonttype: 1,
    },
  );
FazilMuhammed commented 3 years ago

@livingmine Can you share your code please.did you remove all parameters ??

livingmine commented 3 years ago

@FazilMuhammed Yes, remove all parameters, all i have left is just the text to print. Something like this: await BluetoothEscposPrinter.printText( 'Some Text', {} );

FazilMuhammed commented 3 years ago

@livingmine Still also I cannot print in IOS, removed all parameters you said.any other solutions. only I need to print in IOS

usfslk commented 1 year ago

any solution for this issue? I am also unable to pair Epson TMP20 on iOS