简体   繁体   English

持久多人连接配对

[英]Persistent Multipeer Connectivity Pairing

Using the Multipeer Connectivity framework, is there a way to have devices remember who they paired with in the past? 使用Multipeer Connectivity框架,是否可以让设备记住过去与之配对的设备? So that confirming the pairing is required only once and further connections can be made without explicit confirmation. 因此,只需一次确认配对即可,并且无需明确确认即可建立进一步的连接。

Not a bulletproof approach, but you could store the Device Name of the previously connected peers. 这不是一种防弹方法,但是您可以存储以前连接的对等方的设备名称。 Device Names are not guaranteed to be unique, possibly introducing errors or security vulnerabilities, but it might do in a pinch. 设备名称不能保证唯一,可能会引入错误或安全漏洞,但可能会出现紧急情况。

you can assign a unique name to each device by appending a random string to the end of each name and displaying only the part that do not have that string. 您可以通过在每个名称的末尾附加一个随机字符串并仅显示不具有该字符串的部分,来为每个设备分配唯一的名称。

That way you can store with NSDefaults by example the connected device name and call a function on viewWillappear that search for peers and then connect to a remembered device if needed 这样,您可以通过示例使用NSDefaults存储连接的设备名称,并在viewWillappear上调用一个函数来搜索对等设备,然后根据需要连接到记住的设备

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

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