How to handle "no internet connection"

Discussion in 'iOS Programming' started by ethana, Aug 6, 2008.

  1. ethana macrumors 6502a

    Joined:
    Jul 17, 2008
    Location:
    Seattle, WA
    #1
    My app just got denied approval from the App Store. Here is what Apple said:

    "The application works fine when connected to the Internet, however, when no Internet access is available (for example, in Airplane Mode), the application crashes upon opening. Instead of closing by crashing, the application should handle the absence of network access with an error message. The crash logs are attached for your inspection."

    How do I detect no internet and then throw an error message up? I have never done anything like that before. Some sample code would be nice. Thanks!

    Ethan
     
  2. robfarmer macrumors newbie

    Joined:
    Jul 26, 2008
    #2
    Checking Connectivity

    Good to know, error handling and connectivity was the last thing on my todo, makes me wonder how in depth Apple tests the apps.

    The combination of the following two examples on the iPhone Dev site should help you:

    The SeismicXML example has some code you could go through to test conenctivity to a specific domain:

    http://developer.apple.com/iphone/library/samplecode/SeismicXML/listing7.html

    That should see if a specific host is available.

    The Reachability example will tell you if Wifi or cellular is available (not connected, but turned on):

    http://developer.apple.com/iphone/l...ty/index.html#//apple_ref/doc/uid/DTS40007324
     
  3. ethana thread starter macrumors 6502a

    Joined:
    Jul 17, 2008
    Location:
    Seattle, WA
    #3
    And what about popping a dialog to display "Sorry, no Internet".... whats the best way to do that?
     
  4. richard.puckett macrumors newbie

    richard.puckett

    Joined:
    Jul 15, 2008
    Location:
    Seattle, WA
    #4
    Go grab the UICatalog app from the dev site. There are a few Alert examples that should help.
     

Share This Page