Question

I used the Reachability code provided by Apple sample code. When I used cellular data network, it could detect that network. However, once I turned it off and re-run my app again, the Reachability still gave me ReachViaWMAN (NetworkStatus) similar to the cellular network. I tried reboot my iPhone with the celluar data turned off, and ran my app again. The result is the Reachability couldn't reach a host.

I'm really confused now. How to fix this problem?

Was it helpful?

Solution

The Reachability code is just sample code. There are a number of bugs in it. I remember a bug where it failed when a VPN was used for example. I know this code is used pretty much by everyone but Apple never intended it to be some sort of official API.

You are far better off understanding how the underlying APIs work and use those directly in your app. They are not difficult to use and you will catch a number of situations that Reachability does not deal with correctly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top