Class Bluetooth
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
NOTE
ExperimentalBluetooth interface of the Web Bluetooth API provides methods to query Bluetooth availability and request access to devices.
[Value("Bluetooth")]
public class Bluetooth : EventTarget
- Inheritance
-
Bluetooth
- Inherited Members
Remarks
Constructors
Bluetooth()
public Bluetooth()
Properties
Onavailabilitychanged
[Value("onavailabilitychanged")]
public EventHandlerNonNull Onavailabilitychanged { get; set; }
Property Value
ReferringDevice
[Value("referringDevice")]
public BluetoothDevice? ReferringDevice { get; }
Property Value
Methods
GetAvailability()
NOTE
ExperimentalgetAvailability() method of the Bluetooth interface nominally returns true if the user agent can support Bluetooth (because the device has a Bluetooth adapter), and false otherwise.
[Value("getAvailability")]
public Task<bool> GetAvailability()
Returns
- Task<bool>
A Promise that resolves with a Boolean.The Promise will resolve with a value of
falseif access is disallowed byPermissions-Policy: bluetooth, if the user has configured the browser to always resolve withfalse, or if the device does not have a Bluetooth adapter.
Otherwise it will resolve withtrue.
Remarks
The word "nominally" is used because if permission to use the Web Bluetooth API is disallowed by the Permissions-Policy: bluetooth permission, the method will always return false.
In addition, a user can configure their browser to return false from a getAvailability() call even if the browser does have an operational Bluetooth adapter, and vice versa. This setting value ignored if access is blocked by the permission.
Even if getAvailability() returns true and the device actually has a Bluetooth adaptor, this does not necessarily mean that calling RequestDevice(RequestDeviceOptions) will resolve with a BluetoothDevice.
The Bluetooth adapter may not be powered, and a user might deny permission to use the API when prompted.
GetDevices()
NOTE
ExperimentalgetDevices() method of the Bluetooth interface returns an array containing the Bluetooth devices that this origin is allowed to access — including those that are out of range and powered off.
[Value("getDevices")]
public Task<List<BluetoothDevice>> GetDevices()
Returns
- Task<List<BluetoothDevice>>
A {{JSxRef("Promise")}} that resolves with an array of BluetoothDevice objects.
Remarks
RequestDevice(RequestDeviceOptions)
NOTE
ExperimentalBluetooth.requestDevice() method of the Bluetooth interface returns a {{jsxref("Promise")}} that fulfills with a BluetoothDevice object matching the specified options.If there is no chooser UI, this method returns the first device matching the criteria.
[Value("requestDevice")]
public Task<BluetoothDevice> RequestDevice(RequestDeviceOptions options = null)
Parameters
optionsRequestDeviceOptions
Returns
- Task<BluetoothDevice>
A {{jsxref("Promise")}} to a BluetoothDevice object.
Remarks
-Communicating with Bluetooth devices over JavaScript on developer.chrome.com.
RequestLEScan(BluetoothLEScanOptions)
[Value("requestLEScan")]
public Task<BluetoothLEScan> RequestLEScan(BluetoothLEScanOptions options = null)
Parameters
optionsBluetoothLEScanOptions