How to discover already connected devices using the ExternalAccessoryFramework on iOS for a non-MFI Bluetooth device?

90 Views Asked by At

I am writing an app that seeks to discover if the user is already connected to a specialized Bluetooth keyboard that I produce. My peripheral is running Bluetooth Classic, version 3.0, and uses HID to communicate with the iOS device. I cannot use Apple's CoreBluetooth Framework as I am not using BluetoothLE or GATT. I must use Apple's ExternalAccessory framework. As per Apple's rules, I DO NOT need to register with MFI because I use "standard Bluetooth profiles supported by iOS" (see here).

I tried to find the connected Bluetooth peripheral by the following objective-c snippet:

NSArray<EAAccessory *> *accessories = [[EAAccessoryManager sharedAccessoryManager] connectedAccessories];

However, even when my Bluetooth peripheral is connected to the iOS device, I cannot obtain any connectedAccessories when I run this command. Do I need to include a UISupportedExternalAccessoryProtocols field in my info.plist file despite not using MFI? See this related stackoverflow post for the UISupportedExternalAccessoryProtocols field. Do I need to programatically connect with my peripheral in objective-c before it returns as a connected device (even though the iOS device is already connected to the peripheral via Bluetooth)? I am really stuck, and don't know how to proceed. Any help would be much appreciated.

0

There are 0 best solutions below