Post

Replies

Boosts

Views

Activity

Reply to NWPathMonitor returns .unsatisfied the WiFi is back on simulator
I had the same issue. I used a state object to call the network class and declare some variables to handle previous status during network dropdown. Refer the below code. public func start() { NWMonitor.start(queue: workerQueue) NWMonitor.pathUpdateHandler = { [weak self] path in guard let self = self else { return } DispatchQueue.main.asyncAfter(deadline: .now() + 2){ let currentStatus = path.status == .satisfied if self.isConnected != currentStatus { if currentStatus { self.isConnected = true if self.wasDisconnected { self.wasDisconnected = false } } else { self.isConnected = false withAnimation { NavigationManager.shared.showAlert(NetInfoAlert(imageName: "slash", text: "No Connection", cancelAction: { NavigationManager.shared.hideAlert() })) } self.wasDisconnected = true } } self.isCellular = path.usesInterfaceType(.cellular) } } }
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’25