问题
Is it possible to search for beacon data (uuid, url, ...) with a progressive web application using just web technologies that is without using native mobile technologies (Android, ios, ...)?
Thanks in advance.
回答1:
Unfortunately, this is not possible as of July 2020. While Google has been working on the WebBluetooth project to bring support for many bluetooth operations to the browser, at least in Google Chrome implementations on Android 6+, Mac or ChromeOS.
Scanning for beacons is not yet possible as of this writing. The API requires that the OS scan for devices matching a requested criteria, and then let the user choose a device to connect to using a user interface. This essentially rules out beacon detection.
Bluetooth scanning APIs are still in draft form here.
EDIT: The APIs mentioned by @zurfyx in the answer below allow you to scan for and connect to an advertised GATT service, but do not allow you to read the data in the advertisement. This is a critical distinction, as reading the data in the advertisement is the key capability required for actual bluetooth beacon detection. That capability is missing from that API. Without that capability, it is impossible to detect a beacon, it is only possible to connect to a BLE device that might be an Eddystone or other service advertisement-based beacon.
UPDATE July 2020: Safari will not be getting any WebBluetooth APIs at all due to privacy concerns, according to a June 2020 announcement by Apple This makes Bluetooth scanning impossible on iOS we apps for the foreseeable future.
As of July 2020, Chrome does not support scanning arbitrary advertisements. See status here: https://github.com/WebBluetoothCG/web-bluetooth/blob/master/implementation-status.md
回答2:
Disclaimer: I wrote eddystone-web-bluetooth (a library which makes it easy to read and write to an Eddystone device). github@eddystone-web-bluetooth npm@eddystone-web-bluetooth
It is possible to scan for Bluetooth devices by using the Web Bluetooth API (currently supported only by Chrome).
By using Bluetooth GATT service, you can connect to Eddystone devices and send/receive data by communicating following their public specifications (which are basically a list of request codes, and the format in which to send and expect their responses).
These services include information such as:
- URL
- Advertising interval
- Lock state
- and more
By using the Bluetooth standard information you can get to know the most generic device information, such as its id and name:
navigator.bluetooth.requestDevice
@beaufortfrancois wrote the probably first Eddystone Web Bluetooth configuration code (source code / demo), so it is probably worth a read if you want to dig more into this. I learned a lot from it.
来源:https://stackoverflow.com/questions/44630864/progressive-web-app-beacon-search