2

I need to develop an Iphone application which need to know whether the Iphone is connected to internet. If yes, I need load some data from server.

So, is it possible to check internet connection in Iphone? Any suggestion for this issue?

Really appreciate for any suggestions, comments and guides.

Thanks.

4 Answers 4

5

Apple has a commonly used sample for this, Reachability isn't that bad to use, and will show you the path to go down.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi,I just go through the "Reachability" documentation.It is nice. So, when I checking the internet connection, if the internet connection status returned is yes, then it will start load data from server and will insert into application's local database. But what I am worry about is when loading data, if suddenly the internet connection is loss or interrupted, the loading data process will stop, so the data cannot be insert into application's local database completely. When user is using application,the data cannot be fully showed. Have any comments for this issue? Thanks.
@cthesky Show an alert informing the user that they need to get back in range of an internet connection. When the connection comes back, dismiss the alert (if the user hasn't already dismissed it) and resume the download.
0

May want to look at if(navigator.onLine) { onlineCode() } , HTML5 feature and iPhone supports HTML5.

also look into this on SO

Checking online status from an iPhone web app

Comments

0

Best to use Reachability......

Comments

0

Best option is to use Reachability.

You can put a checkmark when you are loading some data from the web(or anywhere) each and everytime.

    -(void)checkInternetConnection
{
    Reachability *r = [Reachability reachabilityWithHostName:@"www.google.com"];
    internetStatus = [r currentReachabilityStatus];
    if ((internetStatus != ReachableViaWiFi) && (internetStatus != ReachableViaWWAN))
    {
        UIAlertView *myAlert = [[UIAlertView alloc]initWithTitle:@"No Internet Connection"   message:@"You require an internet connection via WiFi or cellular network."delegate:self cancelButtonTitle:@"Ok"otherButtonTitles:nil];
        [myAlert show];
        [myAlert release];
        return;
    } 
}

You can simply call this method everytime.

Hope it helps!!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.