AbobosSoftware / cordova-plugin-brother-label-printer

Cordova and Capacitor plugin for Bother Label Printers
MIT License
10 stars 16 forks source link

Empty Array on findPrinter() #29

Closed samratarmas closed 3 years ago

samratarmas commented 3 years ago

Hello team,

Really appreciate your work on this plugin. I am using Brother QL1110nWB label printer, it is not in the list of supported printers in the readme file of this repo. I get an empty array when searching for newtworked or bluetooth printers. I can however connect to this printer on the official Brother label printer app on android. Does this mean that the empty array from doing findNetworkedPrinters() is because the QL1110nWB series is not supported by this plugin?

While browsing through the other opened issues in this repository I saw multiple mentions of passing the printer that you want to find in the findNetworkedPrinter() call. Checking on the js code it does not accept any arguements except for success and failiure callbacks.. could you clarify how (if needed), or where we need to include the model number. I am referring to adding the printer model to the "supported list" as suggested by @robr2112 in: https://github.com/MenelicSoftware/cordova-plugin-brother-label-printer/issues/28#issuecomment-689038355

Lastly, the sample code does not include the part where findPrinter() is called, it directly is setting the printer, is it assumed that we run findPrinter() before that sample code?

Looking forward to your response, Regards Samrat

robr2112 commented 3 years ago

Hi Samrat,

At least part of the reason for the problem is that the SDK framework included with this plugin is down-level. From the "info.plist" inside the framework, it is v3.1.1. The QL-1110NWB printer was not added to the SDK until v3.1.5. So, you must update the SDK.

You may download SDK updates here: https://www.brother.co.jp/eng/dev/mobilesdk/ios/index.aspx

NOTE: The website currently has v3.1.12 and v4.0.2. Future SDK updates will only be made to the v4 series. v4 SDKis backward compatible to v3, so I expect you should be able to drop it in to this plugin without any changes to the Plugin source code (but, I can't 100% guarantee that). However, one issue you may encounter with BOTH of these newer SDKs is that they are now bundled as a "Dynamic" framework instead of a "Static" framework (as the 3.1.1 SDK was).

This will require some changes to the project settings to "Embed and Sign" the framework. I know how to do this in Xcode, for a "native" project, but I am not familiar with how to do this in the Cordova dev environment.

I recommend that @arcadius updates this repository to include a newer version of the framework, ideally v4, and hopefully he can resolve this Dynamic Framework setting issue too.

NOTE: We recently discovered another problem with the SDK WIFI Search on iOS14+. Apple now seems to require some additional items added to the Info.plist for this to work.

Bonjour services

-- As for your other questions, I will also defer to Arcadius on these.

Best regards, Rob

samratarmas commented 3 years ago

Thank you @robr2112 for the insights. MenelicSoftware has been really helping out the community with this plugin, does the developper team have any plans in the near future to upgrade the Brother SDK to version 4 @arcadius ?

A temporary solution for developppers currently having the same issue as us is probably to use the "QL-820NWB" model as the readme on this repo states that model is tested to be working. Do you think that would work in the short term? The "QL-720NW" model is discontinued and not even available for purchase at this time.

Question for @arcadius and @robr2112, which supported Brother Label Printer model would you recommend ( QL-820NWB, or something else that you know works well with the current version of this plugin) based on your personal experience of using them with this plugin?

Once again, we are very grateful for the work that went into the cordova-plugin-brother-label-printer plugin. We have a very small developper team and went the hybrid app route in order to avoid having independednt IOS and Andriod codebases, and from looking at community forums and on Github it seems like label printing from hybrid app is still an issue that has not found a great solution.

Looking forward to your response,

Best regards Samrat

robr2112 commented 3 years ago

Hi @samratarmas,

I can't speak for when the plugin may be updated by @arcadius. But, you can try doing all this yourself.

It will be easy for you to replace the v4 SDK inside the plugin. Just download and replace the BRPtouchPrinterKit.framework with the BRLMPrinterKit.framework....except the name change may require other (minor) modifications to the plugin.xml file. Alternatively, you can just use the v3.1.12 framework for now since the name is the same, and it supports the QL-1110NWB printer.

For embedding the Dynamic framework (v3.1.12 or v4.0.2), here's an SO post describing how. Though, this post is old, 2016. So, now it may be as simple as adding embed="true" when listing the framework in Plugin.xml, assuming Cordova has fixed this. https://stackoverflow.com/questions/36650522/custom-cordova-plugin-add-framework-to-embedded-binaries

And, this is (probably) the only place you would rename the framework to the new name, so you can use v4 if you'd like. As I said, v4 will be compatible with the existing code in this plugin.

Again, if you are testing on iOS14, the Search won't work unless you add the other plist settings I mentioned before. I believe these also need to be added to plugin.xml file, but I'm not sure of the details currently. Printing will still work on iOS14 without these changes. This only affects the WIFI search.

So, if you just want to test QL-1110 quickly with WIFI Search, try it on an iOS13 (or earlier) device. But, you may need to add this model to the PrinterList and/or the SupportedPrinterList in the plugin code.

As for which model to use, TBH, I have not used either QL printer with this plugin, or with the SDK for that matter, as I support a different Brother product line (mobile printers PocketJet and RuggedJet series). Though, the latest SDKs will work fine with both models. So, it's a matter of your preference to which printer to use. If you prefer NOT to modify the plugin at all by yourself, then go with the QL-820NWB at least until the plugin is updated. But, in either case, the WIFI search won't work on iOS14 until the plist changes are made.

Best regards, Rob

arcadius commented 3 years ago

I have found the "Discovery" protocol a bit unreliable as it depends on the security level in the network. If you want consistent result @samratarmas , I would suggest you use a static IP address if you can. And the SDK has now been updated to the latest version