How can I tell if NetService#publish is failing because it lacks permissions?

I'm testing my app on iOS 14. One of its features involves listening for Bonjour connections on the local network using NetService#publish. When my app calls this method for the first time, I get the new iOS 14 popup asking the user if my app should have access to the local network. If they allow access, everything is fine.

However, if the user denies access, my NetService delegate never receives netService(didNotPublish:). I was hoping to get an error code here that I could use to inform the user that the feature isn't working specifically because they disabled the Local Network permission.

Unfortunately, this is not treated as an error condition - the only way I've found to detect this situation at all is that my netService(didPublish:) method never gets called if the Local Network permission has been disabled.

Is there a better way to detect this situation and inform the user that the app needs Local Network access to continue?
Similarly, I'd like to know if NetServiceBrowser#searchForServices fails because of a missing Local Network permission. In that case, I'd expect to receive netServiceBrowser(didNotSearch:), but it's not invoked.
I would open an Enhancement Request for an API to do so. Please add the specific use case you have described while working with NSNetservice and Bonjour. Once you have opened the ER please follow up with the Feedback ID so that I can track it.


Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
Thanks, Matt! I filed Feedback Assistant FB8423040 describing this in more detail.
Since you're suggesting an Enhancement Request, does that mean there's currently no way to detect this situation?
Interferon that does seem to be the case! There are a lot of use holding out hope that Apple will add an API for local network permissions as it currently seems almost impossible to detect.
Thank you for opening the Feedback, I see it internally and have copied myself on it.
In regards to your question:

does that mean there's currently no way to detect this situation

I do not know of any way to query whether the local network permission is failing due to lack of permissions. My advice here would be to checkout the information that the NSNetServiceBrowserDelegate provides you. While iOS 14 is still in Beta and things may shift around here still, there may be more information available in the delegate that provides helpful clues as to what is going on. For example, over in Network Framework, if you start a NWBrowser and look for a Bonjour service after the local network permissions have been denied you will receive a state update of: waiting(-65570: PolicyDenied) in the stateUpdateHandler { ... }. Again, this is still in Beta and thing may still shift around, but as of the time of writing this, that is what I am seeing.


Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
How can I tell if NetService#publish is failing because it lacks permissions?
 
 
Q