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

Initial support for iOS, Bluetooth printing #11

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open

Initial support for iOS, Bluetooth printing #11

wants to merge 26 commits into from

Conversation

gordol
Copy link
Owner

@gordol gordol commented Aug 18, 2017

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 WIP: Add support for iOS and Bluetooth printing #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?

Morgahl and others added 19 commits June 20, 2017 12:13
add ios support

add the ability to set the printer

update the version to 0.0.4 from 0.0.3

add supported printer list

add network printing for iOS

TODO: be able to select the Printer label type. It is currently hard-
coded to use 62mm paper. This needs to be configurable.
when the permissions are listed as required, especially the usb permission,
the number of supported devices drops significantly when uploading to
the Play Store.
WIP: Add support for iOS and Bluetooth printing (android only for now)
Readme update with new function documentation
@gordol
Copy link
Owner Author

gordol commented Aug 18, 2017

@Ayiga are you able to build?

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

@dev-fJ-del
Copy link

dev-fJ-del commented Aug 18, 2017 via email

Theodore Schnepper and others added 4 commits August 18, 2017 09:11
fix Bluetooth paired devices check from trying to return non-Brother Label printers as part of the device list.

loosen restrictions on the List type passed into ImageBitmapPrint
Permissions Check and Cleanup (Previously Missing)
@gordol
Copy link
Owner Author

gordol commented Aug 19, 2017

@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
Copy link
Owner Author

gordol commented Aug 19, 2017

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

@dev-fJ-del
Copy link

dev-fJ-del commented Aug 19, 2017

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

@gordol
Copy link
Owner Author

gordol commented Aug 19, 2017

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

@Ayiga was this pulled over from brother by mistake, or did you need this?

public static final String CUSTOM_PAPER_FOLDER = Environment
.getExternalStorageDirectory().toString() + "/customPaperFileSet/";

@dev-fJ-del Try modifying this line:

mPrinterInfo.customPaper = Common.CUSTOM_PAPER_FOLDER + customSetting;

to

                mPrinterInfo.customPaper = customSetting;

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

@Ayiga
Copy link

Ayiga commented Sep 1, 2017

@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.

@VictorCoding
Copy link

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.

@gordol
Copy link
Owner Author

gordol commented Dec 11, 2017

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

@VictorCoding
Copy link

@gordol i get a 0

@gordol
Copy link
Owner Author

gordol commented Dec 11, 2017

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
Copy link
Owner Author

gordol commented Dec 11, 2017

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
Copy link
Owner Author

gordol commented Dec 12, 2017

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?

@VictorCoding
Copy link

VictorCoding commented Dec 12, 2017

@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.

@Ayiga
Copy link

Ayiga commented Dec 15, 2017

@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. :(

@chetuBhadra93
Copy link

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.

@VictorCoding
Copy link

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

@arcadius
Copy link

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

@VictorCoding
Copy link

VictorCoding commented Jun 19, 2018

@arcadius im using version 9.4.

@KBIOS997
Copy link

KBIOS997 commented Nov 13, 2018

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.

Repository owner deleted a comment Jan 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants