EngstromJimmy / Blazm.Bluetooth

85 stars 14 forks source link

Not showing device selector on android #27

Closed LeagueRaINi closed 7 months ago

LeagueRaINi commented 7 months ago

Tried using this with blazor wasm on android and its not showing the device selector using google chrome (which i know support web bluetooth), works fine on windows, any ideas?

@page "/"

@using Blazm.Bluetooth;

<PageTitle>Home</PageTitle>

@inject IBluetoothNavigator navigator

@if (DeviceSelected)
{
    <p>Selected: @DeviceName</p>
}
else
{
    <button onclick="@Select">Select device</button>
}

@code {
    bool DeviceSelected { get; set; }
    string DeviceName { get; set; } = "None";

    async Task Select()
    {
        var filter = new RequestDeviceQuery();
        filter.Filters.Add(new Filter() { NamePrefix = "ow" });

        var device = await navigator.RequestDeviceAsync(filter);
        if (device != null)
        {
            DeviceName = device.Name;
            DeviceSelected = true;
        }
    }
}

might just be an issue with blazor pwa itself i guess raw

LeagueRaINi commented 7 months ago

seems to work with https

EngstromJimmy commented 7 months ago

Great feedback, thanks for sharing