How to check if user has given permission to access local network?

Hello,

since we should avoid the appearance of the permission popup at launch, we are planning to ask the user specifically at a later point in time.
If the user has given permission and launches next time, we can browse for Bonjour services at launch.

How can we check on launch if the user has given permission or whether we need to ask the user again?

Accepted Reply

Please see this related thread: https://developer.apple.com/forums/thread/650648

There isn't an API to do a pre-flight check for the permission status. For your use case, can you always have the Bonjour browse be based on some user action? Does it need to occur at launch?

Replies

Please see this related thread: https://developer.apple.com/forums/thread/650648

There isn't an API to do a pre-flight check for the permission status. For your use case, can you always have the Bonjour browse be based on some user action? Does it need to occur at launch?
How can I prompt the popup every time if the user already denied local network but still trying to using some functions? We need to handle this and give user the clearly feedback, instead of "unknown error / network error". And we need to fix it before iOS 14 final version released, using Xcode 11, because Xcode 12 beta can't submit.
Post not yet marked as solved Up vote reply of 0x5e Down vote reply of 0x5e
Image if there's no api to get permission status of location, bluetooth, push notification, camera, contact, album, the app user experience will be destoryed.
Hello Frameworks Engineer ,

thanks for your response.

This is very critical for us. We are currently thinking about to which user action we can bind the Bonjour browse. Currently we browse at launch to know if the user has our appliances within the local network so we can directly connect. As fallback we would connect via cloud. But we always prefer local connection over cloud connection. This is better in terms of latency but also regarding privacy of the user. We can only detect this with Bonjour browse.
Otherwise we would need to make assumptions based on wifi SSID (for which we need the location permission).

If I understood correctly the Bonjour browse will not return anything if the user has not granted access to the local network? For our App it would look like there are none of our appliances around to connected locally to. We could not distinguish it from a "real out house" scenario and would always connect via cloud.

We would like to detect if the user has given or denied access to local network and have a possibility to give our users some context why some functionality is not working at all (our wifi setup and appliance pairing) or working worse than before (connecting via cloud to a local appliance and thus suffering from higher latency).

Thanks
I have also created a topic in Feedback Assistant: FB7867125
I think it would at least be helpful to receive a call to
netServiceBrowser(_:didNotSearch:)(https://developer.apple.com/documentation/foundation/netservicebrowserdelegate/1410567-netservicebrowser)
but of course anything we can actively retrieve similar like CLAuthorizationStatus (https://developer.apple.com/documentation/corelocation/clauthorizationstatus) would give us the ability to provide best user experience.

Thanks✌️
Checking for kDNSServiceErr_PolicyDenied works for us now and we can detect if local network privacy permission has not been granted by the user. I will close this issue.

However I have a follow up question regarding the initial value .ready for NWBrowser.State:
https://developer.apple.com/forums/thread/666431