cordova-plugin-bluetoothle
cordova-plugin-bluetoothle copied to clipboard
retrieveConnected not returning any paired devices on iOS 14.3
On iOS 14.3, retrieveConnected()
appears to always return an empty array, and never returns any paired devices. Per the documentation, I am specifying an array of service UUIDs.
In my case I have a paired blood pressure monitor. I confirmed via the iOS Bluetooth settings that the device is paired, yet I am unable to get retrieveConnected
to return this device. I've tried using service UUIDs for the Blood Pressure service ("1810"), device information service ("180A"),current time service ("1805"), and battery service ("180F"), all of which I know are available on the blood pressure monitor, yet nothing is ever returned.
Is it possible there's a bug in the retrieveConnected
method with iOS 14? I have had no issues on Android, and it works as expected.
To test, I have just been calling the method like this:
bluetoothle.retrieveConnected(console.log, console.error, {services: ["1810", "180f"]})
Did some digging, and I believe the issue, at least for me, is that in iOS the plugin is using the method CBCentralManager.retrieveConnectedPeripheralsWithServices, which seems to only return information for peripherals that are actively connected to. Perhaps this didn't used to be the case, but as far as I can tell it is the case for iOS 14.
For my particular use case, I will actually be able to utilize another method in iOS, CBCentralManager. retrievePeripheralsWithIdentifiers, which allows retrieving information for paired devices based on their address/peripheral UUID. However, it looks like iOS may not offer any method to retrieve information on paired devices that are not connected, other than by their address.