Bluetooth.requestDevice()

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 of BluetoothScanFilters. This filter consists of an array of  BluetoothServiceUUIDs, a name parameter, and a namePrefix parameter.
  • optionalServices[]: An array of BluetoothServiceUUIDs.

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).

License

© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/bluetooth/requestdevice