I'm currently doing a project with the web bluetooth in js and I wonder if there is a way to save the device object and automatically connecting to it instead of choosing the device in the pop up every time.
I've tried saving the device in the local storage and tried to get it in the cookies but they both failed.
There is a way, but it implies enabling some Chrome feature flags on a Chrome 85+
You can have a look at the documentation.
To sum it up, after enabling those two feature-flags in chrome://flags :
The Web Bluetooth spec will be updated with the algorithm for getDevices(). The devices returned by getDevices() may contain devices that are not currently in range and connected. The BluetoothDevice::watchAdvertisements() API can be used to detect when Bluetooth devices come into range of the Bluetooth radio. Then calling BluetoothRemoteGATTServer.connect() should resolve successfully if the device is able to be connected to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With