Tag: reachability

How to use Reachability class to detect network status?

I am creating an app which requires internet. I want to use reachability class in my project and I want to detect if user has no internet connection whatever the technique is either wifi, Cellular. I want a step by step guide for this.

Reachability with Address – Server AND Port – iOS 5

I am trying to check whether a server is online or offline: I face the problem that it has a port when connecting to it My code at the moment: struct sockaddr_in address; address.sin_len = sizeof(address); address.sin_family = AF_INET; address.sin_port = htons(25667); address.sin_addr.s_addr = inet_addr(“fr7.mooshroom.net”); Reachability *reachability = [Reachability reachabilityWithAddress:&address]; Please let me know what […]

How to check for network reachability on iOS in a non-blocking manner?

In my iOS project, I would like to display a message to the user to connect to the internet before certain network operations, so I wrote the following check using Apple’s Reachability class: Reachability *reach = [Reachability reachabilityWithHostName:@”google.com”]; if([reach currentReachabilityStatus] == NotReachable) { // …prompt user to establish an internet connection } else { // […]

Detecting internet connectivity continually

I want my app to detect the internet connection loss automatically. So im using the following code. – (void)applicationDidBecomeActive:(UIApplication *)application { Reachability *networkReachability = [Reachability reachabilityForInternetConnection]; NetworkStatus networkStatus = [networkReachability currentReachabilityStatus]; if (networkStatus == NotReachable) { [Settings hideSpinner]; //Show no internet connectivity dialog. } else { } } But the problem is that it is […]

App crashing when using Reachability Classes to check for internet connection

I’m using this code to check for an internet connection but I’m getting a crash saying +[Reachability reachabilityForInternetConnection]: unrecognized selector sent to class 0xcbe0c8 I’ve imported Reachability .h/.m and the systemconfig framework. Crash is at line self.internetRechable = [[Reachability reachabilityForInternetConnection] retain]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkNetworkStatus:) name:kReachabilityChangedNotification object:nil]; self.internetRechable = [[Reachability reachabilityForInternetConnection] retain]; [self.internetRechable startNotifier]; // […]

kReachabilityChangedNotification is called multiple times

I’m using the Reachability classes for checking when I got an internet connection en when it goes down. This is my code: IN VIEW DID LOAD: internetReachable = [Reachability reachabilityForInternetConnection]; [internetReachable startNotifier]; // check if a pathway to a random host exists hostReachable = [Reachability reachabilityWithHostname:@”www.google.com”]; [hostReachable startNotifier]; Then the notification method -(void) checkNetworkStatus:(NSNotification *)notice […]

Where should I perform a Reachability check?

I want to check for a valid network connection. I followed Apple’s Reachability example and put my check in applicationDidFinishLaunching #pragma mark – #pragma mark Application lifecycle – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { if(getenv(“NSZombieEnabled”) || getenv(“NSAutoreleaseFreedObjectCheckEnabled”)) { NSLog(@”NSZombieEnabled/NSAutoreleaseFreedObjectCheckEnabled enabled!”); } // Override point for customization after application launch. [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(reachabilityChanged:) name: […]

AFNetworking 2.0 Reachability not working

I’m having some trouble making AFNetworking Reachability module to work. I have setup my AFHTTPRequestOperationManager with a ReachabilityStatusChangeBlock but it’s never being called. self.manager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:[NSURL URLWithString:@”http://192.168.1.2:3000″]]; self.manager.responseSerializer = [AFJSONResponseSerializer serializer]; NSOperationQueue *operationQueue = self.manager.operationQueue; [self.manager.reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { switch (status) { case AFNetworkReachabilityStatusNotReachable: // we need to notify a delegete when internet […]

Reachability responding with wrong status code in iOS 7 iphone 5

I am facing weird problem on iPhone 5 with iOS 7, i have tested same code with other devices like iPad1, 2, 3 and iPhone 4, 4s etc. with different iOS combination including iOS 7. Problem : When i turn on airplane mode i do get reachability notification as expected with status NotReachable but immediately […]

How to define a reachability timeout on ios

I use the Reachability class to know if I have an internet connection available. The problem is when wifi is available but not internet, the – (NetworkStatus) currentReachabilityStatus method take too much time. my code: Reachability* reachability = [Reachability reachabilityWithHostName:@”www.apple.com”]; NetworkStatus remoteHostStatus = [reachability currentReachabilityStatus]; The application “freeze” temporarily on the second line. How to […]