Bluetooth: prohibiting or detecting unwanted pairing request alert on connect

When calling CBCentralManager's connectPeripheral:options: with some Bluetooth devices I'm getting the "Bluetooth Pairing Request" alert on iOS and a similar "Connection Request from:" alert on macOS. Is there a way to determine upfront if the alert is going to be presented or not? Alternatively is there a way to prohibit presenting this alert (in which case the connect request could fail, which is totally fine)? I tried specifying these options:

var manager: CBCentralManager
...
manager.connect(
    peripheral,
    options: [
        CBConnectPeripheralOptionNotifyOnConnectionKey: false,
        CBConnectPeripheralOptionNotifyOnDisconnectionKey: false,
        CBConnectPeripheralOptionNotifyOnNotificationKey: false
    ]
)

but those didn't help (and by the doc they shouldn't help as they relate to the use case of app running in background, which is not applicable in my case – my app runs and calls connect when it is in foreground, the unwanted alert is displayed immediately).

Replies

It's probably related to the "Just Works" pairing method that DOESN'T happen in those cases I am seeing the alert.

Got some heavy-wight workaround idea sketch: split the app into two with the second one being background only process. Specify CBConnectPeripheralOptionNotifyOnConnectionKey / CBConnectPeripheralOptionNotifyOnDisconnectionKey, CBConnectPeripheralOptionNotifyOnNotificationKey keys being false and make the "connect" call from there. Then somehow (XPC?) communicate data back to the main app.

There must be an easier way!

Anyone knows?