iOS 配对设备重新连接的代表

delegate of iOS paired device reconnection

我有一个应用程序正在使用 retrieveConnectedPeripheralsWithServices 来获取配对 HID devices 的列表。我可以使用 connectPeripheral 代码获取列表并成功连接到所需的列表。连接成功后,将调用以下委托:

- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral

对于断开连接,我得到相应的委托:

- (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error

现在,当 HID device 再次连接到 iOS 时(直接来自设置,而不是来自我的应用程序),我想得到通知。有什么方法可以查明 HID device 何时重新连接到 OS?

终于找到答案了

感谢@Paulw11 的指导,基于 Apple Documentation:

When the user leaves home, the iOS device may eventually become out of range of the lock, causing the connection to the lock to be lost. At this point, the app can simply call the connectPeripheral:options: method of the CBCentralManager class, and because connection requests do not time out, the iOS device will reconnect when the user returns home.