Class DeviceRequestPrompt
- Namespace
- PuppeteerSharp
- Assembly
- PuppeteerSharp.dll
Device request prompts let you respond to the page requesting for a device through an API like WebBluetooth.
public class DeviceRequestPrompt
- Inheritance
-
DeviceRequestPrompt
Examples
var promptTask = Page.WaitForDevicePromptAsync();
await Task.WhenAll(
promptTask,
Page.ClickAsync("#connect-bluetooth"));
var devicePrompt = await promptTask;
await devicePrompt.SelectAsync(
await devicePrompt.WaitForDeviceAsync(device => device.Name.Contains("My Device")).ConfigureAwait(false)
);
Remarks
DeviceRequestPrompt instances are returned via the WaitForDevicePromptAsync(WaitForOptions).
Properties
Devices
Current list of selectable devices.
public List<DeviceRequestPromptDevice> Devices { get; }
Property Value
Methods
CancelAsync()
Cancel the prompt.
public Task CancelAsync()
Returns
- Task
A task that resolves after the cancel message is processed by the browser.
SelectAsync(DeviceRequestPromptDevice)
Select a device in the prompt's list.
public Task SelectAsync(DeviceRequestPromptDevice device)
Parameters
device
DeviceRequestPromptDeviceThe device to select.
Returns
- Task
A task that resolves after the select message is processed by the browser.
WaitForDeviceAsync(Func<DeviceRequestPromptDevice, bool>, WaitForOptions)
Resolve to the first device in the prompt matching a filter.
public Task<DeviceRequestPromptDevice> WaitForDeviceAsync(Func<DeviceRequestPromptDevice, bool> filter, WaitForOptions options = null)
Parameters
filter
Func<DeviceRequestPromptDevice, bool>The filter to apply.
options
WaitForOptionsThe options.
Returns
- Task<DeviceRequestPromptDevice>
A task that resolves to the first device matching the filter.