Reachability.swift: Reachability(hostname: host) does not work
My IPad is connected to an Wifi hotspot without any connection to the internet. If I try this code, I receive true.
let host = "www.google.com"
let reachability: Reachability
do {
reachability = try Reachability(hostname: host)
nwAvailable = reachability.isReachableViaWiFi()
} catch {
...
}
If the hotspot has internet or the wifi is disconnected, the code works very well.
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 4
- Comments: 22 (2 by maintainers)
I don’t think you can fix it while using the SCNetworkReachability interface. From the SCNetworkReachability Apple docs:
You’d have to be able to send something to the remote host and get a response to cover this edge case. Something like a ping or small network request. That’s not a perfect solution either as some router configurations block incoming pings.
Up!
how to monitor internet checking in this case:- I have connected to WIFI but ,i turned off my internet connection,in this case notify method is not calling