cordova-brother-label-printer icon indicating copy to clipboard operation
cordova-brother-label-printer copied to clipboard

Initial support for iOS, Bluetooth printing

Open gordol opened this issue 7 years ago • 21 comments

Todo

  • Label size is currently hard-coded and specified on calls to setPrinter

  • The supported printer list only contains printers I have tested personally, Brother QL-720NW and Brother QL-820NWB. With changes to allow for the changing of the label type, this would likely support all brother label printers, but it needs to be tested by someone with access.

  • iOS has bluetooth issues according to @Ayiga in #10

  • Documentation/readme needs to be updated.

  • Need to test! Anyone have a basic iOS Cordova app to test this with? Should we include a boilerplate example with this plugin to help users get started?

gordol avatar Aug 18 '17 06:08 gordol

@Ayiga are you able to build?

Building status: error (List<Bitmap> cannot be converted to ArrayList<Bitmap>)

gordol avatar Aug 18 '17 09:08 gordol

https://github.com/gordol/cordova-brother-label-printer/pull/11/files#diff-7ffdcc51506a24e861e75e002ed22eddR19

gordol avatar Aug 18 '17 09:08 gordol

Hi, for the life of me, I cannot seem to call the findPrinters function, do you perhaps know how to translate this typescript to javascript?

Sample:

function findPrinters(success: (printers: Printer[]) => void, failure: (reason: string) => void): void

What I've got: cordova.plugins.brotherPrinter.findPrinters(function (a) { alert(a); }, viewModel.onSuccess, viewModel.onError);

or even this does not want to work:cordova.plugins.brotherPrinter.findPrinters(viewModel.onSuccess, viewModel.onError);

Thank you for the assistance!

On Fri, Aug 18, 2017 at 11:20 AM, Thomas Gordon Lowrey IV < [email protected]> wrote:

https://github.com/gordol/cordova-brother-label-printer/ pull/11/files#diff-7ffdcc51506a24e861e75e002ed22eddR19

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gordol/cordova-brother-label-printer/pull/11#issuecomment-323304353, or mute the thread https://github.com/notifications/unsubscribe-auth/ATzouekyVnyr6i5vOXsvHRzLNH5Bg6I2ks5sZVdtgaJpZM4O7Ku4 .

dev-fJ-del avatar Aug 18 '17 10:08 dev-fJ-del

@dev-fJ-del You should just be able to call findPrinters(). It takes two parameters, a success callback, and a failure callback.

Your second example looks correct to me.

findPrinters(onSuccess, onError);

That being said, I have not actually tested this PR yet, that's why it's on the dev branch.

gordol avatar Aug 19 '17 09:08 gordol

Can you send any log outputs? You should see some log messages if any printers are found. Are you receiving any errors?

gordol avatar Aug 19 '17 09:08 gordol

Ok, I got it to work up until where it calls the printViaSDK, I get the error: "ERROR_WRONG_CUSTOM_INFO" I checked the sdk docs :

Error: Wrong information in custom paper setting file

No idea what to do from here on. The printer I'm using is the RJ-4040

dev-fJ-del avatar Aug 19 '17 12:08 dev-fJ-del

This is some of the new stuff... Hmm...

@Ayiga was this pulled over from brother by mistake, or did you need this? https://github.com/gordol/cordova-brother-label-printer/blob/9d882751c985589cf2ddf872b3e4dfc39904f13f/src/android/Common.java#L87-L88

@dev-fJ-del Try modifying this line: https://github.com/gordol/cordova-brother-label-printer/blob/9d882751c985589cf2ddf872b3e4dfc39904f13f/src/android/BasePrint.java#L343

to

                mPrinterInfo.customPaper = customSetting;

Basically, remove the CUSTOM_PAPER_FOLDER bit... and let me know if it works?

gordol avatar Aug 19 '17 13:08 gordol

@gordol I can build what I had currently without issues. I'll have to repull this repo to make sure everything still works on this end.

as far as the CUSTOM_PAPER_FOLDER setting, it was just code that was copied from Brother. I did a quick pass to remove or modify stuff that I thought wasn't necessary, and I may have missed some things. I believe the custom paper settings are for larger printers, but I'm not certain, they are likely not necessary.

Ayiga avatar Sep 01 '17 16:09 Ayiga

I've purposely been triggering a network error to occur when calling printViaSDK by having my ipad connected to a different network than that of the brother printer, however the callback never gets runned, instead I see this in my safari and xcode consoles error: Error occured while WLAN printing. Which is line 557 in BrotherPrinter.m file.

https://github.com/gordol/cordova-brother-label-printer/blob/dev/src/ios/BrotherPrinter.m#L557

It would be great if the callback actually got triggered with a good error as a response that way I can handle that on the js side. Otherwise, the js side has no idea why the printer didn't print since the callback never gets invoked. Any help would be appreciated.

VictorCoding avatar Dec 11 '17 23:12 VictorCoding

@VictorCoding What is outputted by this line? NSLog(@"Communication Result: %d", result); Is it empty?

gordol avatar Dec 11 '17 23:12 gordol

@gordol i get a 0

VictorCoding avatar Dec 11 '17 23:12 VictorCoding

I'm not super familiar with this IOS code, but looks like the meat of that is happening here: https://github.com/gordol/cordova-brother-label-printer/blob/dev/src/ios/BRWLANPrintOperation.m

communicationResultForWLAN is a boolean.

What do you have if you dump: wlanOperation.resultStatus? resultStatus comes from getPTStatus via: https://github.com/gordol/cordova-brother-label-printer/blob/dev/src/ios/libs/BRPtouchPrinterKit.framework/Headers/BRPtouchPrinter.h

My objective C isn't very strong, I'll need to brush up on some basics before I can be of more help.

gordol avatar Dec 11 '17 23:12 gordol

Can you put some debug logging here, to see if your printer is ready?

https://github.com/gordol/cordova-brother-label-printer/blob/dev/src/ios/BRWLANPrintOperation.m#L61

gordol avatar Dec 11 '17 23:12 gordol

I don't know the details of the IOS Brother SDK, but it seems to me, that what you want are two things... Callbacks for failure to associate with the printer, and a callback for failure to print.

On Android, we don't allow a call to printViaSDK unless a printer is found.

resultstatus should have what you need, right?

gordol avatar Dec 12 '17 00:12 gordol

@gordol The printer is NOT ready so it skips to line 77. In my javascript implementation for setPrinter's my success callback is invoked, which then I call printViaSDK, but that's when I dont get my callback invoked.

btw, thanks for your assistance even if your objective c game is rusty. at least it's better than me, i dont know objective c at all.

VictorCoding avatar Dec 12 '17 16:12 VictorCoding

@gordol @VictorCoding

I believe this is due to the original code for handling the callback in the javascript file:

https://github.com/gordol/cordova-brother-label-printer/blob/dev/www/printer.js#L24

And the Original: https://github.com/gordol/cordova-brother-label-printer/blob/master/www/printer.js#L15

As you can see in that file, all errors just get console logged instead of passed back to the user. It's one of the things I worked to fix with this pull request:

https://github.com/ayiga/cordova-brother-label-printer/blob/master/www/printer.js#L50

But, I haven't been able to come back to this project and update it so that it's "good enough". I will push what I have, but I have added some quick and dirty solutions for what I needed in my particular use case without really addressing the talking points @gordol brought up before. I just haven't had the time to come back, and give it the attention it needs, unfortunately. :(

Ayiga avatar Dec 15 '17 23:12 Ayiga

Hello, Thanks for this great plugin for iOS. I successfully print label for my Brother QL-810 printer. But currently I am receiving one issue, that I am receiving printer in onFailure of findNetworkPrinter method. Please find following code please guide me where I am doing wrong.

cordova.plugins.brotherPrinter.findNetworkPrinters((success) => {}, (error) => {})

thanks in advance.

chetuBhadra93 avatar Jan 05 '18 11:01 chetuBhadra93

@chetuBhadra93 could you provide the actual data you're getting from the onFailure callback?

VictorCoding avatar Jan 05 '18 16:01 VictorCoding

Hello @gordol , @VictorCoding @Ayiga ....

Not sure what version of XCode you guys are using ... After installing this plugin dev branch, my project will not even compile in Xcode .... please see more detail on #34

arcadius avatar Jun 19 '18 08:06 arcadius

@arcadius im using version 9.4.

VictorCoding avatar Jun 19 '18 14:06 VictorCoding

img_20181113_130324 Hellp @gordol and @VictorCoding I have use your brother label printer sdk. SDK working fine. When I call printviaSDK method. Getting success response. But printer doesn't print any image. response getting success but noting happen.

KBIOS997 avatar Nov 13 '18 07:11 KBIOS997