如何使用iOS 14触发多播授权的本地网络对话框授权 [英] How to trigger the local network dialog authorization for multicast entitlement using iOS 14

查看:1030
本文介绍了如何使用iOS 14触发多播授权的本地网络对话框授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

遵循iOS 14的新政策,即禁止访问本地网络,需要com.apple.developer.networking.multicast特殊权利才能访问本地网络,并且该访问应由用户在授权对话框中确认.尽管尚未对此新功能进行详尽记录,但Apple工程师在论坛上指出,仅当应用程序尝试发送流量时才会触发此授权对话框弹出窗口,从而导致仅读取网络的应用程序出现问题,如

Following iOS 14 new policy of blocking access to local network, a com.apple.developer.networking.multicast special entitlement is needed to access the local network, and this access should be confirmed by user during an authorization dialog. Although this new feature is not thoroughly documented, Apple engineers have indicated in forums that this authorization dialog popup is only triggered when the app tries to send traffic, causing an issue for apps reading only the network, as indicated in iOS 14 How to trigger Local Network dialog and check user answer?

不幸的是,在我们的案例中,发送一些数据以触发授权对话框的建议似乎不起作用,因为我们从未出现过弹出对话框.

Unfortunately, the advice of sending some data to trigger the authorization dialog does not seem to work in our case, as we never got the popup dialog appearing.

我们的应用程序通常仅接收UDP广播(除了少数情况,不发送).我们已获得com.apple.developer.networking.multicast权利,已将其添加到我们的应用程序权利中,已在Info.plist中添加了所请求的NSLocalNetworkUsageDescription,并使用XCode 12.0手动配置了我们的应用程序,其配置文件包括该权利(在这种情况下,需要进行 https://developer.apple .com/forums/thread/656773?answerId = 628537022 ).从那时起,情况有所改善,因为在添加权利之前被完全阻止的UDP数据包接收有时会开始起作用,但不幸的是并非总是如此(iOS 14.0.1的情况似乎比iOS 14和iPhone的情况要差,而iPad的情况似乎更糟).

Our app usually only receive UDP broadcast (no transmit except in a few cases). We have got the com.apple.developer.networking.multicast entitlement, have added it to our app entitlements, have added the requested NSLocalNetworkUsageDescription in our Info.plist and are signing our app manually using XCode 12.0 with a provisioning profile including this entitlement (manual code signing is needed in this case as indicated in https://developer.apple.com/forums/thread/656773?answerId=628537022). Since then, situation has somewhat improved as the UDP packet reception that was fully blocked before adding the entitlement started to work sometimes, but unfortunately not always (situation seems worse on iOS 14.0.1 than on iOS 14 and on iPhone than on iPad).

最重要的是,我们从未显示过授权对话框,并且我们的应用程序未在隐私/本地网络"中显示为已授权(即使UDP接收有效).我们怀疑这可能是造成此伪造接收问题的原因.似乎授权对话框仅在发送数据时显示,我们使用以下所有方法将应用程序配置为将数据发送到本地网络,以尝试触发该对话框:

Most importantly, we never got the authorization dialog displayed and our app does not appear as authorized in Privacy/Local Network (even when UDP reception works). We suspect this may be the cause for this spurious reception issue. As it seems the authorization dialog is only shown when sending data, we configured our app to send data to the local network to try to trigger the dialog, using all below methods:

  • TcpSocket class (using CFStreamCreatePairWithSocketToHost) to connect to 192.168.1.1 on port 80 and send a few bytes (there is a device at this address)
  • using GCDAsyncSocket to connect and send a test TCP packet to same address/port
  • using GCDAsyncUdpSocket to create a UDP socket, enabling it for broadcast, then joinMulticastGroup 224.0.1.0 and broadcasting a test UDP packet on port 80.
  • using GCDAsyncUdpSocket to create a UDP socket, enabling it for broadcast, then broadcasting a test UDP packet on port 80 to 255.255.255.255.
  • reusing the example from Apple article (https://developer.apple.com/news/?id=0oi77447) sending multicast packets with NWConnectionGroup to 224.0.1.0
  • and finally using the triggerDialog() method of class LocalNetworkPermissionService indicated in iOS 14 How to trigger Local Network dialog and check user answer?

以上操作均未触发iOS 14.0和iOS 14.0.1上的授权对话框,并且我们的应用仍未在隐私/本地网络"中列为已授权,并且会虚假接收UDP数据包.

None of the above actions triggered the authorization dialog on iOS 14.0 and iOS 14.0.1, and our app is still not listed as authorized in Privacy/Local Network, with spurious reception of UDP packets.

如果有人遇到相同的问题并找到了解决方案,非常感谢您的建议.

If somebody has encountered the same issue and found a solution, many thanks for your advice.

推荐答案

感谢@Columbo,并得到了Apple的帮助,尽管仍未完全了解问题的根本原因,但已经找到了解决方案.

Thanks to @Columbo and help from Apple, a solution has been found, although the root cause of the issue is not yet fully understood.

我们的应用程序的iOS发行版部署目标是9.0,因为我们试图保持与旧设备的兼容性.似乎较低的部署目标12.0可能会导致网络隐私管理出现问题.解决方案是:

Our app was built with a iOS release deployment target of 9.0 because we tried to preserve compatibility with older devices. It seems a deployment target lower 12.0 may cause issue with the network privacy management. The solution was then:

  • 在将iOS部署目标更新为12.0或更高版本后重建应用程序.
  • 对于已经安装了该应用程序先前版本的所有iOS 14.0和14.0.1设备,要完全删除该应用程序并再次安装(更新该应用程序还不够,仍然不会显示网络隐私警报). /li>
  • to rebuild the app after updating the iOS deployment target to 12.0 or higher.
  • for all iOS 14.0 and 14.0.1 devices having a previous version of the app already installed, to fully delete the app and install it again (updating the app was not sufficient, the network privacy alert was still not shown).

当然,此过程对于需要从头开始重新安装应用程序并重新配置的用户而言并不理想.如果将来的iOS版本可以避免此问题,我将更新此线程.

Of course, this procedure is not ideal for users that will have to reinstall the app from scratch and configure it again. I will update this thread if a future version of iOS avoids this issue.

更新:使用iOS 14.2时,即使在升级后(未完全删除并重新安装),该应用程序仍会正确触发网络隐私警报.然后,我们建议用户在升级我们的应用程序之前先升级到14.2.我们将部署目标保持在12.0

Update: when using iOS 14.2, the app is correctly triggering the network privacy alert even after an upgrade (without full deletion and reinstall). We then recommended our users to upgrade to 14.2 before upgrading our app. We have kept the deployment target at 12.0

这篇关于如何使用iOS 14触发多播授权的本地网络对话框授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆