Summary
Allow bluetooth access to devices that the user has already paired with from a service worker.
Security / Privacy
-
The user would have to selected and paired the device.
-
We could have an additional permission that says “This app would like to connect to bluetooth devices in the background.”
-
This functionality could also additionally be limited to installed PWAs
Native
Currently this functionality is available in native, and unless there are plans to remove background bluetooth access from native I can’t see good arguments for not allowing it at least for installed PWAs.
Use Case
Quick Summary: For receiving and printing online orders.
Detailed:
In each shop we have a POS terminal (either an ipad or an Android tablet) with a POS software running as a PWA.
There are two (or more) printers:
-
A Label Printer
-
A Thermal Receipt Printer
When an order is placed on the system, labels are printed using the label printer so they can be stuck on the box and a receipt is printed on the thermal printer. In this case the PWA is active and can just use web-bluetooth as normal as long as both devices are connected.
Online Orders are received through the server, while the application is running it’s possible to open a web-socket connection to receive the online order and then immediately print both a label and a receipt when one is received. The issue is when the application is not active as the staff often need to switch to other apps.
The ideal solution would be to use PUSH API to wake a service worker, which can immediately connect to the bluetooth printers and print. This way if the device is idle or a user is using another application the printing process can continue uninterrupted.
Note that this entire process is possible within native apps, but is not possible with service workers / web-bluetooth. I realize there are possible privacy/security concerns, but I think a good general stance is if you can do it on native, you should be able to do it on the web. If the privacy/security risks are too big to be mitigated by any process then that functionality should also be removed from native.
Push API
There are current issues with devices that are in sleep mode not waking the service worker. To fix that issue we would likely need a method of labelling high priority push which is guaranteed to wake the device.