When the router is empty, the status is always unsatisfied.

When the router is empty, the status is always unsatisfied.

At this time, pathUpdateHandler does not respond even if you switch WiFi ON / OFF.

If the IP address of the connectable device is set to the router, the status will switch to satisfied / unsatisfied by turning WiFi on / off.

Since it is used only in the local area network, the router is not set.

import Network
import SwiftUI

class WiFiNetwork : ObservableObject {
    private let wifiMonitor = NWPathMonitor(requiredInterfaceType: .wifi)
    
    func startWiFiMonitor() {
        let queue = DispatchQueue(label: "wifiMonitorQueue")
        wifiMonitor.pathUpdateHandler = { path in
            if path.status == .satisfied {
                print("##### WiFi Connected")
            } else {
                print("##### WiFi not Connected")
            }
        }
        wifiMonitor.start(queue: queue)
    }
}

Do you have a question?

I want to check if I'm connected to WiFi, not if I can connect to the internet. If the router is empty, can't I check it with NWPathMonitor?

When the router is empty, the status is always unsatisfied.
 
 
Q