iPhone SDK Internet connection detection

If your application must have network access the easiest way is to add the following settings to your info.plist as boolean values.

  • SBUsesNetwork - Ensure the device has an active connection (Edit: not applicable, this seems to be a private API someone found at some point. It is not in Apple's developer documentation.)
  • UIRequiresPersistentWiFi - Ensures the device is connected via WiFi

If your choice is not true then the user will be presented with an appropriate message when starting your application. Best of all this message is from the OS and thus is localized.

If your application cannot download data from a website while running (loss of signal, site down) you should still warn the user though and not just spin indefinitely.


Apple Developer Connection has a sample application (Reachability) that uses the System Configuration framework to determine network status. It will tell you whether you have a WiFi, EDGE/3G or no Internet connection.

You would use portions of this code in your application to determine network state, and then provide interface cues if no connection is available, such as a UIAlertView.


Cautionary word: beware SBUsesNetwork. I would personally love to know where SBUsesNetwork originally came from, because it's not mentioned anywhere in Apple's docs that I can find. When I add the key to my app's plist (as a boolean) and set to true, it doesn't seem to affect the behaviour of my app -- I get no warning about airplane mode, whether starting app completely afresh, or foregrounding a previous launch that was backgrounded.

My app has UIRequiresPersistentWifi set to true, which appears to also do the job people claim SBUsesNetwork does (plus other things!).

(I'm running iOS4.2.1 on an iPhone 4, XCode 3.2.5 64 bit).