Posts

Post not yet marked as solved
4 Replies
Reposting code block: let port = NWEndpoint.Port(rawValue: UInt16(80))! self.connection = NWConnection(host: host, port: port, using: .tcp) self.connection?.stateUpdateHandler = { latestState in if #available(iOS 14.2, *) { if self.connection?.currentPath == nil { return } else if self.connection?.currentPath?.unsatisfiedReason == .localNetworkDenied { // permission is not granted } else { // permission is granted } } }
Post not yet marked as solved
4 Replies
The issue comes back sometimes when I re-install the app (uninstall and then install). Here is a code snippet of the method I use to check if the permission is denied: let host = NWEndpoint.Host(someLocalNetworkAddress) let port = NWEndpoint.Port(rawValue: UInt16(80))! self.connection = NWConnection(host: host, port: port, using: .tcp) self.connection?.stateUpdateHandler = { latestState in if #available(iOS 14.2, *) { if self.connection?.currentPath == nil { return } else if self.connection?.currentPath?.unsatisfiedReason == .localNetworkDenied { // permission is not granted } else { // permission is granted } } } When the issue occurs, I always get the currentPath as unsatisfied and the unsatisfiedReason as localNetworkDenied even though the permission toggle is on for my app in the settings app.