First update in NWBrowser.stateUpdateHandler is always .ready

We are using NWBrowser.State to check to for NWError.dns(DNSServiceErrorType(kDNSServiceErr_PolicyDenied)) to identify if the user has granted local network privacy permission, which was introduce with iOS14.
This works fine so far but we are seeing that the first update in NWBrowser.stateUpdateHandler after nwBrowser.start is always ready. To overcome this and not respond to a false-positive, we currently need to debounce this first value.
Is this the expected behaviour or a Bug in NWBrowser?

we are seeing that the first update in NWBrowser.stateUpdateHandler after nwBrowser.start is always ready.

I have seen this as well and just reconfirmed it on iOS 14.2. I suspect what is happening is that NWBrowser is technically in the .ready state but waiting for the Local Network Privacy action to be allowed/denied for further state update. Notice if you allow the prompt, that there is no update to the .ready state. Notice if you deny the prompt that the -65570: PolicyDenied is provided in the browser's .waiting state error.debugDescription reflecting this current state. Now, on a subsequent launch of a previously denied privacy prompt you will also see the same behavior as the first denied. For example, as you mentioned, NWBrowser goes into ready but then does provide the -65570: PolicyDenied failure if you take a look at the debugDescription of the error passed into the .waiting(let error) state here. For this I would always key off the latest updated state and when Local Network Privacy errors are involved you will usually find them in .waiting.


Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
First update in NWBrowser.stateUpdateHandler is always .ready
 
 
Q