简体   繁体   English

iOS配对设备重新连接的委托

[英]delegate of iOS paired device reconnection

I have an application which is using retrieveConnectedPeripheralsWithServices to get the list of paired HID devices . 我有一个应用程序正在使用retrieveConnectedPeripheralsWithServices来获取已配对的HID devices的列表。 I can get the list and connect to the desired one successfully using connectPeripheral code. 我可以获取列表并使用connectPeripheral代码成功连接到所需的列表。 When the connection succeeds, following delegate is being called: 连接成功后,将调用以下委托:

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

and for disconnection, I get the corresponded delegate: 对于断开连接,我得到了相应的委托:

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

Now when the HID device gets connected again to the iOS ( directly from Setting, not from my application ), I want to be informed. 现在,当HID device再次连接到iOS时( 直接从Setting而不是从我的应用程序 ),我希望得到通知。 Is there any way to find out when an HID device reconnected to the OS? 有什么方法HID device何时重新连接到OS?

Finally, I found the answer. 最后,我找到了答案。

Thanks to @Paulw11 for his guidance, based on Apple Documentation : 感谢@ Paulw11根据Apple文档提供的指导:

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. 当用户离开家时,iOS设备最终可能会超出锁的范围,从而导致与锁的连接丢失。 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. 此时,应用程序可以简单地调用CBCentralManager类的connectPeripheral:options:方法,并且由于连接请求不会超时,因此当用户返回家园时,iOS设备将重新连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM