Best solution I've found is to use the .waiting state from NWBrowser - https://developer.apple.com/documentation/network/nwbrowser/state/waiting. Ping the local network using NWBrowser and track the browser state using stateUpdateHandler, or just manually check the state when necessary. If the user denies access you will get the .waiting state.
See: https://developer.apple.com/forums/thread/658151
Note: You will need the com.apple.developer.networking.multicast - https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_networking_multicast entitlement, which must be requested from Apple. Without this entitlement you will always get the .denied state even if the user gives access. You will also need Xcode 12.