User permission is now required to communicate from iOS 14 to the local network. For example, if you use broadcast or multicast to automatically detect devices on your local network, the following alert dialog will be displayed to the user. In iOS14, I thought that I just asked the user for permission, but depending on the function, it is necessary to change the implementation or apply to Apple. See the URLs listed in Resources for more information.
["Support local network privacy in your app (WWDC2020)"] In (https://developer.apple.com/videos/play/wwdc2020/10110/), if the user has permission to communicate with the local network, it is explained as follows.
--Communicate with local network host via TCP / UDP --Search and advertising on Bonjour --IP multicast, broadcast, ICMP communication
When using a local network, what you need as a developer is as follows.
The following dialog will be displayed when the app requires permission for the local network. If nothing is set, you will see a standard description of the figure, such as Introduction
. You can add a descriptive text to this dialog by putting a descriptive text in ʻInfo.plist`. You can explain to your users why your app needs it.
Specifically, edit ʻInfo.plist in Xcode and the value of
Privacy --Local Network Usage Description` will add a descriptive text.
The file of ʻInfo.plist` is as follows.
Info.plist
<key>NSLocalNetworkUsageDescription</key>
<string>Please describe in this part.</string>
When searching for a service in Bonjour, enter the service name to be searched in ʻInfo.plist. The services listed here will be discoverable by Bonjour. Edit ʻInfo.plist
in Xcode and add the service to search to Bonjour services
. Since it is an array, you can list more than one.
Info.plist
<key>NSBonjourServices</key>
<array>
<string>_ipp._tcp.</string>
<string>_printer._tcp.</string>
</array>
If you need broadcast / multicast communication other than the above, you need to apply to Apple for each app ID. Specifically, ["Multicast Networking Entitlement Request"] You can apply from (https://developer.apple.com/contact/request/networking-multicast). iOS simulators and iPad OS simulators can communicate without this permission. However, on the actual machine, communication is not possible without this permission. If you can communicate with the simulator but not with the actual device, please check if this permission is required.
After getting the Multicast Networking Entitlement
from Apple, some settings are needed. I will write the setting method.
Select the target app ID. Specifically, select the target app from ʻIdentifiers of
Certificates, Identifiers & Profiles` of Apple Developer in the figure below.
The current URL is https://developer.apple.com/account/resources/identifiers/list.
After selecting the target app ID, you can change the app settings with ʻEdit your App ID Configuration. For apps that have acquired
Multicast Networking Entitlement, you will be able to select ʻAdditional Capabilities
as shown in the figure below, so select Multicast Networking
.
Select the file with app name.entitlements
in Xcode. Put com.apple.developer.networking.multicast
in key
and 1
in value
as shown in the figure below.
This completes the Capability settings.
It is the description method in the following file.
app name.entitlements
<key>com.apple.developer.networking.multicast</key>
<true/>
--[To use a multicast network with the app] (https://developer.apple.com/jp/news/?id=0oi77447)
Recommended Posts