It seems that iOS doesn't support "Password Credentials" when pairing with Bluetooth, but there are other options. I know that Confirm Pin Match works for authenticating but haven't tried to provide an application defined PIN. The below works for me...
C# (.NET, In the csproj, target framework is: net6.0-windows10.0.19041.0):
using Windows.Devices.Bluetooth;
using Windows.Devices.Enumeration;
...
public async Task PairAsync()
{
// false in this case means the AQS string will be formatted to look for unpaired devices.
// can also use a DeviceWatcher to asynchronously search for devices.
var foundDevices = await DeviceInformation.FindAllAsync(BluetoothDevice.GetDeviceSelectorFromPairingState(false));
// we're assuming we've found one that we want to connect to, but you'll need to do some type of filtering.
var device = foundDevices[i];
var bluetoothDevice = await BluetoothDevice.FromIdAsync(device.Id);
// NOTE: you can also request access to the available RFCOMM services before or after pairing:
// var servicesResponse = await device.GetRfcommServicesAsync(BluetoothCacheMode.Uncached);
// hook the pairing event
device.DeviceInformation.Pairing.Custom.PairingRequested += Custom_PairingRequested;
// you can mess with DevicePairingProtectionLevel as you see fit. OBEX profiles require some amount of encryption.
// DevicePairingKinds.ConfirmPinMatch is what causes the PIN to display on the iOS device that the user accepts
var pairResponse = await device.DeviceInformation.Pairing.Custom.PairAsync(
DevicePairingKinds.ConfirmPinMatch,
DevicePairingProtectionLevel.EncryptionAndAuthentication);
}
private void Custom_PairingRequested(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args)
{
// do something to display PIN to user or if you have a custom pin that was displayed in your app, verify it.
args.Accept(args.Pin);
}
Links:
-
DevicePairingKinds: https://docs.microsoft.com/en-us/uwp/api/windows.devices.enumeration.devicepairingkinds?view=winrt-22621
-
DevicePairingProtectionLevel: https://docs.microsoft.com/en-us/uwp/api/windows.devices.enumeration.devicepairingprotectionlevel?view=winrt-22621
-
PairAsync: https://docs.microsoft.com/en-us/uwp/api/windows.devices.enumeration.deviceinformationcustompairing.pairasync?view=winrt-22621
Hope this provides some amount of insight or because this is 2 months old you've already figured something out.
-Drew