Post

Replies

Boosts

Views

Activity

Reply to UDP Listener on iOS 14
Right, because if your UDP listener never receives any messages then you’ll never start the outgoing TCP connection. I was able to receive UDP packets and then set up a TCP connection without triggering the network permissions, so long as I wasn't using Bonjour. This was on iOS 14 with no entitlements listed in the info.plist, and an empty Bonjour array. I was under the impression that you’re using UDP broadcasts? If so, NWListener and NWConnection are not appropriate. I am. My current implementation (updated from the OP) is to receive the UDP broadcasts via an NWListener (which uses Bonjour) and then set up an NWConnection on the port to read the messages. This is functional on iOS 14. Emailing with Network Entitlement Requests suggested I should accomplish the UDP reception via Bonjour, so I implemented the below. Should I be using something different? 	var udpListener: NWListener?   var udpConnection: NWConnection?   var backgroundQueueUdpListener  = DispatchQueue.main       func findUDP() {     let params = NWParameters.udp     udpListener = try? NWListener(using: params, on: 15000)           udpListener?.service = NWListener.Service.init(type: "_appname._udp")           self.udpListener?.stateUpdateHandler = { update in       print("update")       print(update)       switch update {       case .failed:         print("failed")       default:         print("default update")       }     }     self.udpListener?.newConnectionHandler = { connection in       print("connection")       print(connection)       self.createConnection(connection: connection)       self.udpListener?.cancel()     }     udpListener?.start(queue: self.backgroundQueueUdpListener)   }       func createConnection(connection: NWConnection) {     self.udpConnection = connection       self.udpConnection?.stateUpdateHandler = { (newState) in         switch (newState) {         case .ready:           print("ready")           self.send()           self.receive()         case .setup:           print("setup")         case .cancelled:           print("cancelled")         case .preparing:           print("Preparing")         default:           print("waiting or failed")         }       }       self.udpConnection?.start(queue: .global())   }       func endConnection() {     self.udpConnection?.cancel()   }
Sep ’20
Reply to UDP Listener on iOS 14
Thanks, Eskimo. Hopefully these steps will solve my UDP receiving issues. I will update your answer as a solution once I am able to check. I have already populated NSLocalNetworkUsageDescription in my Info.plist. I just applied for the com.apple.developer.networking.multicast permissions, and will enable them once granted. I use the info I get from my UDP listener to set up a TCP connection... so far, this has not triggered the local network privacy alert. I do not use NWConnection or any other Apple library for this, rather Swiftsocket - https://github.com/swiftsocket/SwiftSocket. Would the multicast entitlement result in my TCP connection triggering the network permissions? I've also been able to use NWListener to set up an NWConnection on the UDP port, which does trigger the local network privacy alert. If using this, do I still need an entitlement? Do I need to alter my TCP connection at all (it doesn't trigger a privacy alert when I run it alone, and am not sure if this is an issue)? Thanks for your help. I am straying a bit off topic here so please let me know if an email might be better for this.
Sep ’20