This article needs a technical review. How you can help.
This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.
The Bluetooth.requestDevice() method of the Bluetooth interface returns a Promise to a BluetoothDevice object with the specified options. If there is no chooser UI, this method returns the first device matching the criteria.
Syntax
Bluetooth.requestDevice(options).then(function(bluetoothDevice) { ... })
Returns
A Promise to a BluetoothDevice object.
Parameters
- options
- An object that sets options for the device request. The available options are:
filters[]: An array ofBluetoothScanFilters. This filter consists of an array ofBluetoothServiceUUIDs, anameparameter, and anamePrefixparameter.optionalServices[]: An array ofBluetoothServiceUUIDs.
Example
navigator.bluetooth.requestDevice(options).then(function(device) {
console.log('Name: ' + device.name);
// Do something with the device.
})
.catch(function(error) {
console.log("Something went wrong. " + error);
});
Specifications
| Specification | Status | Comment |
|---|---|---|
| Web Bluetooth The definition of 'requestDevice()' in that specification. |
Draft | Initial definition. |
Browser compatibility
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
|---|---|---|---|---|---|
| Basic support | 45.0 [1] |
| Feature | Android | Android Webview | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
|---|---|---|---|---|---|---|---|---|
| Basic support | No support | No support | 48.0 [2] |
[1] Behind a flag. Chrome OS only.
[2] Behind a flag. Requires Android 6 (Marshmallow).