AFNetworkReachabilityStatus with inconsistent values when re-establishing connection

0

I'm trying to use the RestKit framework to observe the changes in the connection through the setReachabilityStatusChangeBlock method of the AFHTTPClient class. Once the application is started I get the AFNetworkReachabilityStatusReachableViaWiFi value, and when the internet connection is disabled I get the AFNetworkReachabilityStatusNotReachable value. But when the connection is reestablished, most of the time I keep getting AFNetworkReachabilityStatusNotReachable .

    
asked by anonymous 28.05.2015 / 10:44

1 answer

1

Are you talking about RestKit or AFNetworking?

Well, let's face it.

SCNetworkReachability is for you to monitor your network status, it can not tell you if a host is online or offline, but can tell if it is reachable, that is, if your network (not the device) , can access the host.

One of the things I see around here is for people to use SCNetworkReachability or Reachability (which is an abstraction of SCNetworkReachability developed by Apple), to test a network connection and then trigger a request for a service remote.

In my opinion, this is a total waste of time, since this way, your app takes longer to request a service and the user expects more. In addition, network status may change in the interval between the test and the triggering of the actual request.

In case you are using SCNetworkReachability or Reachability to test the network and then trigger an inquiry, I recommend you do the opposite, trigger the query even if you do not know if you have networking and do the error handling later.

This post shows you how to use this approach correctly.

In another case where you just want to display the networking status on the screen, for example, use SCNetworkReachability or Reachability .

I hope I have helped.

    
27.06.2015 / 20:44