Check permission granted for accessing local network?

I have searched the web for hours but can not find a way to request local network permission in my app.

I have added NSLocalNetworkUsageDescription to info.plist but I can not find a way to trigger a dialog prompt to request access or handle things gracefully.

I have a UDP socket that opens when the user presses go however on first installs the privacy prompt appears when the socket opens, after the user pressed go, so now there is a prompt shown in front of everything while the session and timers are now running.

Is there any way to prompt the user for network access prior to starting a session? My impression is that without this ability it's just bad UX and I think most users will be very confused when prompt appears while also session starts running but the network is inaccessible.

I think I saw other similar forum topics but none of them had solutions, is there a solution now in 2022 or any way to help improve the user experience of my app? Id like to somehow request network access with a way to handle the result programmatically?

Is there any way to prompt the user for network access prior to starting a session?

There is no API to pre-flight the local network privacy prompt or check if the persmission has been granted. One technique that has been used is to run a local network connection or task in you app to get this out of the way when the app starts up. For example, Triggering the Local Network Privacy Alert has worked for some folks in the past, but if you have a local network connection that can be run on startup that pertains to the functionality of your app then this would be even more ideal.

Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
Check permission granted for accessing local network?
 
 
Q