5

hi How do you display a Alert when not connected to the internet ? iOS

not connected to internet means has no wifi , no connection to remote host ( www.google.com)

no Cellular Data Network

as i have seen many applications showing this message when i am not connected to the internet.

i have tried downloading the Reachability from apple dev resources however it does not give me what i want of implementing the codes into my .h .m file.

hope to get a reply.

AlsonToh-SG
  • 145
  • 3
  • 14
  • What's your question? The reachability app is a good start for example code, but you'll need to understand it to code your own solution. SO isn't somewhere to come for teh codez. – Codebeef Oct 14 '10 at 11:24
  • check out: [stackoverflow answer here][1] [1]: http://stackoverflow.com/questions/8812459/easiest-way-to-detect-a-connection-on-ios – hanumanDev Nov 17 '12 at 06:23

1 Answers1

4

Code to do this is here.

http://developer.apple.com/library/ios/samplecode/Reachability/

You can call:

    self.remoteHostStatus           = [[Reachability sharedReachability] remoteHostStatus];
    self.internetConnectionStatus   = [[Reachability sharedReachability] internetConnectionStatus];
    self.localWiFiConnectionStatus  = [[Reachability sharedReachability] localWiFiConnectionStatus];
Jordan
  • 21,598
  • 10
  • 48
  • 63
  • hmm jordon i have followed the first reply however , it does not work. – AlsonToh-SG Oct 14 '10 at 13:55
  • Be more specific. What happens, what doesn't work? Did it crash? What makes you think it's not working? – Jordan Oct 14 '10 at 15:48
  • I revised my answer. The previous answer did not work in the simulator. You should have better look adding Reachability.h/.m to your project. – Jordan Oct 14 '10 at 16:42
  • http://www.youtube.com/watch?v=NkpYlpbrC1M < was looking for something like this. – AlsonToh-SG Oct 18 '10 at 02:06
  • Yes. In my answer, there is code to the Reachability classes. Download and add similarly to the video you linked to. – Jordan Oct 18 '10 at 02:46
  • hmm jordan may i ask you , as i have seen another similar video , it shows that the user does not use a reachability class but instead another set of codes to check if webview does launches , thus will apple still accept this? – AlsonToh-SG Oct 18 '10 at 14:07
  • alright thanks jordan . hope it helps , will update you if my app did get inside :) – AlsonToh-SG Oct 20 '10 at 01:49
  • hi Jordan i have launched my application it's called NPCourses , thanks for your help :) – AlsonToh-SG Jul 31 '11 at 15:08