auctifera-josed / starprnt

Cordova plugin for the Star micronics printers
MIT License
40 stars 39 forks source link

New Android Bluetooth permissions preventing print and port discovery #60

Open davidclean opened 1 year ago

davidclean commented 1 year ago

When trying to print to Bluetooth using Android 12 or above am receiving an error message that BLUETOOTH_CONNECT permission is required.

Running the following function will result in app crash

starprnt.portDiscovery('All', function (result) {

davidclean commented 1 year ago

good discussion of the issue here: https://stackoverflow.com/questions/67722950/android-12-new-bluetooth-permissions

and here: https://developer.android.com/guide/topics/connectivity/bluetooth/permissions

igorsantos07 commented 1 year ago

The crash is probably the same we faced at #48 and fixed at #59 - however, with a new perm request. Upgrading to Android 12 left us in a strange endless loop of search (our fork got a bit outdated, missing a new argument), and fixing that causes an instant error now.

Sadly, as you can see, this plugin is abandoned. But you're welcome to try our fork, I'm trying to solve the issue.

igorsantos07 commented 1 year ago

@davidclean were you able to get to a solution, by any chance?

Edit: turns out the USB permission issue seems to be mysteriously gone, but right now I'm unable to test bluetooth printers (got none working with me, but a colleague have and will report on this in the near future). What I can say is: bluetooth permissions are not needed to search for printers, at least.

image

davidclean commented 1 year ago

@igorsantos07 I haven't been able to find a solution yet unfortunately

davidclean commented 1 year ago

@igorsantos07 workaround solution i'm trying is to use this plugin https://www.npmjs.com/package/cordova-plugin-android-permissions before attempting to print or search for printers

igorsantos07 commented 1 month ago

While our fork solved crashes and hangs, in some scenarios permissions were not requested - or we were not able to re-request when possible. I went with a slightly different path of yours - I used https://github.com/dpa99c/cordova-diagnostic-plugin, which has some extra functionalities that could be useful, besides being more detailed on the permission status. It became quite a convoluted function to work out all the scenarios, but it worked well in the end 🤷

Thanks for the pointers!