Skip to content

Bluetooth.ScanForDevices() returning empty collection on iOS. Works fine on Android. #457

@DanOrlovsky

Description

@DanOrlovsky

Environment
.Net MAUI 8.0
iPhone 14 Pro Max
iOS 18.3.2

I'm advertising a GATT service from a Raspberry pi and would like to communicate with that service from an Android & iOS app.

I'm finding the devices using:

var filter = new BluetoothLEScanFilter();
filter.NamePrefix = "RASPBERYPI";

var options = new RequestDeviceOptions();
options.Filters.Add(filter);
var devices = await Bluetooth.ScanForDevicesAsync(options);

This works fine when I debug on Android. It's turning up empty (immediately) when I debug on iOS.

I do get back PermissionStatus.Granted when I request them:

PermissionStatus status = PermissionStatus.Unknown;
if ((await Permissions.CheckStatusAsync<Permissions.Bluetooth>()) != PermissionStatus.Granted)
{
    status = await Permissions.RequestAsync<Permissions.Bluetooth>();
}

And I've also added bluetoothle to the required device capabilities:

<key>UIRequiredDeviceCapabilities</key>
<array>
	<string>arm64</string>
        <string>BluetoothLE</string>
</array>

(I've also tried adding the NSBluetoothAlwaysUsageDescription key's and the UIBackgroundModes bluetooth keys).

I'm not sure what to try next.

Any help or at least direction would be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions