I'm trying to force the connectivity over cellular only , without much luck so far, the wifi is always used unless it's turned off
Any idea?
Any idea?
Code Block var connection: NWConnection? func startConnection(url: URL) { let pathMonitor = NWPathMonitor() pathMonitor.pathUpdateHandler = { path in if path.usesInterfaceType(.wifi) { print("Path is Wi-Fi") } else if path.usesInterfaceType(.cellular) { print("Path is Cellular") } else if path.usesInterfaceType(.wiredEthernet) { print("Path is Wired Ethernet") } else if path.usesInterfaceType(.loopback) { print("Path is Loopback") } else if path.usesInterfaceType(.other) { print("Path is other") } } pathMonitor.start(queue: .main) let params = NWParameters.tls params.requiredInterfaceType = .cellular params.prohibitExpensivePaths = false params.prohibitedInterfaceTypes = [.wifi] let connection = NWConnection(host: NWEndpoint.Host(url.host!), port: 443, using: params) self.connection?.stateUpdateHandler = { (newState) in print("This is stateUpdateHandler:") switch (newState) { case .ready: print("State: Ready\n") case .setup: print("State: Setup\n") case .cancelled: print("State: Cancelled\n") case .preparing: print("State: Preparing\n") default: print("ERROR! State not defined!\n") } } connection.start(queue: .main) self.connection = connection print(connection.debugDescription) }