views:

58

answers:

1

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.

+1  A: 

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
hmm jordon i have followed the first reply however , it does not work.
AlsonToh-SG
Be more specific. What happens, what doesn't work? Did it crash? What makes you think it's not working?
Jordan
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
http://www.youtube.com/watch?v=NkpYlpbrC1M < was looking for something like this.
AlsonToh-SG
Yes. In my answer, there is code to the Reachability classes. Download and add similarly to the video you linked to.
Jordan
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
If it's not using Private API's it'll be accepted.
Jordan
alright thanks jordan . hope it helps , will update you if my app did get inside :)
AlsonToh-SG