【发布时间】:2021-04-07 08:59:42
【问题描述】:
我的应用程序使用 bonjour 服务通过本地网络相互对话。 我在使用 OS14 设备的 Xcode12 上遇到问题。
设备发布服务类型名称取决于自身设备 IP 地址 (例如:192.168.33.20 -> _1921683320._tcp)
B 设备搜索服务类型的服务取决于 A 设备 IP 地址 (例如:_1921683320._tcp)
根据苹果文档..来自OS14~
https://developer.apple.com/documentation/multipeerconnectivity
Important
Apps that use the local network must provide a usage string in their Info.plist with the key NSLocalNetworkUsageDescription. Apps that use Bonjour must also declare the services they browse, using the NSBonjourServices key.
因为我的服务类型名称是本地网络ip命名的,它可以根据本地网络设置进行更改,所以我正在考虑使用通配符来定义服务类型名称。
示例:_*._tcp
但是这个定义似乎没有通配符。(我试过了)
我也在考虑改变A设备上的命名方式 (例如:192.168.33.20 -> _20._tcp) 并将 _1.tcp ~ _255.tcp 添加到 info-plist
但是如果我改变了命名方法,B设备直到版本更新才能找到A设备。
对这个问题有什么想法吗?请帮忙。
【问题讨论】:
标签: wildcard ios14 xcode12 multipeer-connectivity