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)
}
}