0

What do you think would be the best way to handle no network connectivity?

My future app heavily relies on network and without it there will be nothing to do with it.

I see apps handling the situation in different ways.

When I don't have connection the ebay app for example sometimes pulls the last saved data, but some other time it just clears everything out. Paypal app will either log me out or it will just crash. One of the news app will just keep say loading...

Is there any best practicies out there?

Should the app keep trying and display loading message, add a refresh button or just close the app automatically?

Thank you

Cyntech
  • 5,362
  • 6
  • 33
  • 47
user643097
  • 127
  • 2
  • 15
  • 1
    Not really a programming question but rather a design one :) It also isn't related to dealing with the NSURLConnection class... – Zaky German May 16 '11 at 15:33

4 Answers4

0

Easiest thing first: You should never ever close the app yourself, and you should never crash.

If displaying old data is appropriate in your case, just do so and maybe add some notice on the screen that the user is offline.

If there is really nothing the use can do without online access, gray everything out or use a similar technique.

Keep trying to reconnect in background (i.e. listen to network availability changes) and behave appropriately.

One thing to keep in mind: With mobile devices there are often short disconnects that you want to handle gracefully.

Eiko
  • 25,601
  • 15
  • 56
  • 71
0

Have a look at ASIHttpRequest, it has a great caching mechanism.

rckoenes
  • 69,092
  • 8
  • 134
  • 166
0

if there is no network connectivity in you application then it's better to say "No network connectivity" kind of message rather than showing loading/refreshing etc.

Or storing the data in database would also be a good option , At least user can play with the data in offline mode, and also your application will be used in offline mode as well. (As you mentioned My future app heavily relies on network and without it there will be nothing to do with it. ).

Make sure, your application should not crash when the network is unavailable.

Jhaliya - Praveen Sharma
  • 31,697
  • 9
  • 72
  • 76
0

What the proper handling of "no network" condition is, entirely depends on your application.

Two things to keep in mind: programmatically closing an app or not handling smoothly the "no connection available" case are both reasons for rejection in the Apple review process.

Having had experience with designing an app that also heavily depended on network being available, I would say that best practice can be summarized in the following:

1) use the Reachability framework to detect what kind of connectivity you have; the version I link to is to be preferred to the one provided by Apple, which is buggy (search S.O for more on this);

2) each time you need data from the network, check whether connection is back (i.e., not just once at the beginning);

3) always inform the user that no network is available, when this occurs, either by displaying an alert, or better showing some other kind of icon/messaging; the least intrusive kind of display is best, so to not disrupt the user's workflow;

4) if you have cached data and this makes sense, use cached data when no network connection is available (this will make the app "partially usable" in such cases as well);

5) offer the user a button to refresh the data, if this make sense for your app;

This said, the simplest implementation of this "best practice" is an app that in case no connection is available, gets the user back to the "main screen" (ugly, but it could be the only sensible thing in your app). Full implementation is, say, an rss reader caching all the news and allowing you to read them even when no connection is there (without loading newer data, obviously).

sergio
  • 68,819
  • 11
  • 102
  • 123