How to correctly handle unavailability of internet connections in iOS?

2.2k views Asked by At

I'm making an app which uses internet. I remember there was something developers had to do with CFNetwork or similar regarding check if availability or speed.

Is there some kind of standard UIAlertView with the message "It seems you have no internet, but you need it for this app"?

Is there a tutorial or guide which show how to do it?

3

There are 3 answers

2
Ankit Srivastava On BEST ANSWER

Apple provides Reachability class to check for this,

Here is a very simple and effective example.

http://tympanus.net/codrops/2009/09/14/checking-network-reachability-iphone/

UPDATE:

It seems that Apple has updated their reachability class and included the singleton pattern. You can check out the new classes here... http://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html

thanks @Proud Member for pointing it out.

0
Ashley Mills On

To test and monitor network availability, you should use the Reachability class in Apple's sample code - http://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html

There's no standard alert for lack of network availability - how you handle the situation depends on the app you're writing.