munder
munder

Reputation: 137

How best to deal with no internet connection in iOS app

I'm working on an app which administers surveys. It stores on the device as much data as makes sense, but there are points in the app where it makes no sense for the user to proceed if they have no Internet connection. So, if the user has already logged in successfully once, their details are pulled from a local SQLlite db, the login screen is skipped and they go straight to a menu of surveys they can choose to answer. If there is amongst those a survey which they have already completed, they can choose to edit their answers. At that point, the survey questions should already be in the device's local database, but I need to download all their answers from the server in case they've modified them using a different device. Also, of course, if they want to start a new survey, I need to retrieve the questions. If they have no Internet connection they need to stop at that point. I display a dialog informing them that they have no Internet connection and should try again later. That's all working fine. I also display a similar dialog if the user has an Internet connection, but the host is unreachbale, but what do I do after the dialog? In Android I can exit the app when they dismiss the dialog, but Apple frown on forcing apps to close, so what do I do on an iOS device? Just hope the user eventually goes away and does something else?

Upvotes: 3

Views: 1577

Answers (3)

Chris Wagner
Chris Wagner

Reputation: 20993

I'd probably present a UIAlertView or some kind of modal that the user can't dismiss, then once Reachability or whatever mechanism reports that the connection is available again, dismiss the alert/modal programmatically.

Quitting the app on the user is pretty abrupt and will likely get your app rejected from the AppStore.

EDIT:

Ultimately it sounds like all you want to do is prevent them from proceeding with the surveys, not necessarily prevent them from using the app. It sounds like you just need a "staging" area/view that tells them what is going on and why they can't take any surveys at the moment. Take a look at other apps that require an always on connection, such as Pandora, Netflix, Hulu, etc... what happens when you open their app in AirPlane mode or kill your WiFi while you're using it?

Upvotes: 4

skytz
skytz

Reputation: 2201

Giving this situation i think Apple won't reject your app if you put a dialog before you exit.

Something like "The server is unreachable and this app doesn't function without that. The app will now close. Thank you and have a nice day!"

You could try explaining the situation if your binary gets rejected.

Upvotes: -1

rog
rog

Reputation: 5361

You could create a retry button in your dialog that'll try to re-establish the connection.

Or you could set up an NSTimer to check for the connection at a set duration. This seems like the most viable, as it'll allow the user to continue editing their survey.

Upvotes: 4

Related Questions