Using showBluetoothAccessoryPicker causes SceneDelegate presenting errors

594 Views Asked by At

I currently have an app that will try to automatically discover a MFi bluetooth device.

The only way is to use the ExternalAccessory framework, as CoreBluetooth only files Ble devices.

Right now I have a button that executes:

EAAccessoryManager.shared().showBluetoothAccessoryPicker(withNameFilter: nil) { error in }

In order for the picker to appear, I need to add var window: UIWindow? inside my AppDelegate

So far this works. The picker shows, and will list the device I want to connect to. However When I try clicking the device for it to pair, I get this message:

2020-11-11 14:07:16.694761-0700 BT[500:48034] [Presentation] Attempt to present <UIAlertController: 0x105013a00> on <_TtGC7SwiftUI19UIHostingControllerV2BT11ContentView_: 0x104a0a510> (from <_TtGC7SwiftUI19UIHostingControllerV2BT11ContentView_: 0x104a0a510>) which is already presenting <UIAlertController: 0x105052800>.

Which does make sense. Currently the picker is presenting and then another alert is trying to be displayed to validate the pin and pair.

But if I delete the Application Scene Manifest in the info.plist, delete the SceneDelegate and remove all UISceneSession Lifecycle functions in the AppDelegate, it works..

The issue is I need the SceneDelegate as it's a swiftUI app and will fail to run otherwise.

Has anyone ran into this issue before?

0

There are 0 best solutions below