Reachability Help - WiFi Detection

I have imported Reachability into my application and I have some tips for everyone. Let me first explain my application and other tools.

This application interacts with two things at the same time, on the ad-hoc network and on the Internet via 3G. Note. The ad hoc network is NOT connected to the Internet. This works great - it has already been implemented and is being tested well.

With that said, I want to implement Reachability to detect two things.

1) Is the user connected to an ad-hoc wifi network? (Better yet, if possible, is to determine if it is connected to a wifi wireless network with the WXYZ prefix. For example, if there are two networks listed, one is called Linksys and the other is called WXYZ-Testing_Platform, it knows whether it is connected to WXYZ).

2) Can a user connect to the Internet via 3G (or 2G, etc.) and gain access to our server?

Thanks in advance

EDIT ENABLING ANSWER FOR FUTURE VIEWS:

For 1) my code is as follows:

.h #import <SystemConfiguration/CaptiveNetwork.h> //for checking wifi network prefix .m - (BOOL) connectedToWifi { CFArrayRef myArray = CNCopySupportedInterfaces(); // Get the dictionary containing the captive network infomation CFDictionaryRef captiveNtwrkDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0)); NSLog(@"Information of the network we're connected to: %@", captiveNtwrkDict); NSDictionary *dict = (__bridge NSDictionary*) captiveNtwrkDict; NSString* ssid = [dict objectForKey:@"SSID"]; if ([ssid rangeOfString:@"WXYZ"].location == NSNotFound || ssid == NULL) { return false; } else { return true; } } 

And for 2) , I imported Reachability and use this method every time I connect to the server ... NOTE: replace http://www.google.com with server information

 -(void) checkIfCanReachServer { UIAlertView *errorView; Reachability *r = [Reachability reachabilityWithHostName:@"http://www.google.com"]; NetworkStatus internetStatus = [r currentReachabilityStatus]; if(internetStatus == NotReachable) { errorView = [[UIAlertView alloc] initWithTitle: @"Network Error" message: @"Cannot connect to the server." delegate: self cancelButtonTitle: @"OK" otherButtonTitles: nil]; [errorView show]; } } 
+7
source share
1 answer

Reachability lets you know if a device can successfully send out packets. So for 1) you should contact your iPhone to get the SSID without a private library . For 2) you will only use Reachability to check your Internet connection, then you will need to use NSURLConnection or another network library to make sure that you can connect to your server.

+7
source

All Articles