Is it possible to run a method that will return the name of the wireless network that the user is connected to? Inside of my app I want to be able to return the name of the wireless network that the user is connected to.
-
1Have a look at this question: http://stackoverflow.com/questions/5198716/iphone-get-ssid-without-private-library – Ian L Nov 02 '12 at 13:02
3 Answers
This worked perfect for me:
#import <SystemConfiguration/CaptiveNetwork.h>
CFArrayRef myArray = CNCopySupportedInterfaces();
CFDictionaryRef myDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));
// NSLog(@"SSID: %@",CFDictionaryGetValue(myDict, kCNNetworkInfoKeySSID));
NSString *networkName = CFDictionaryGetValue(myDict, kCNNetworkInfoKeySSID);
if ([networkName isEqualToString:@"Hot Dog"])
{
self.storeNameController = [[StoreDataController alloc] init];
[self.storeNameController addStoreNamesObject];
}
else {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle: @"Connection Failed"
message: @"Please connect to the Hot Dog network and try again"
delegate: self
cancelButtonTitle: @"Close"
otherButtonTitles: nil];
[alert show];

- 229
- 4
- 15
-
What about releasing the return values of CNCopySupportedInterfaces and CNCopyCurrentNetworkInfo? Documentation states that you "MUST" release the return values. – Stavash Dec 03 '13 at 14:23
-
The BAD NEWS: 'CNCopyCurrentNetworkInfo' is deprecated: first deprecated in iOS 9.0 - For captive network applications, this has been completely replaced by
. For other applications, there is no direct replacement. Please file a bug describing your use of this API to that we can consider your requirements as this situation evolves. The GOOD NEWS: although deprecated, it still works in iOS 9, AND it has been un-deprecated in iOS 10. – Ron Reuter Sep 09 '16 at 17:47 -
An update to @RonReuter's comment: it is properly deprecated now, and does not function in iOS 13 (always returns the same wifi ssid) – xaphod Sep 09 '19 at 18:12
-
Actually, it still works fine in iOS 13, but requires several steps to get it working properly. You have to add an entitlement to access WiFi information, implement some CLLocationManager methods to get access to location information, and you have to add one or two info.plist items with a message to show the user when your app asks for information. Its non-trivial, but it does still work and now seems to be supported by Apple. – Ron Reuter Feb 21 '20 at 15:57
From Developer.apple , you can use CNCopyCurrentNetworkInfo
It Returns the current network info for a given network interface.
CFDictionaryRef CNCopyCurrentNetworkInfo (
CFStringRef interfaceName
);
It contains a dictionary that containing the interface’s current network info. Ownership follows the Create Rule.
Note:Available in iOS 4.1 and later.
EXAMPLE:
This example will work fine in real device, It may crash in simulator.
Add SystemConfiguration.framework
Import CaptiveNetwork
header same as below
#import <SystemConfiguration/CaptiveNetwork.h>
Then write the below code.
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"];
NSLog(@"network name: %@",ssid);
or
Using Bonjour, the application both advertises itself on the local network and displays a list of other instances of this application on the network
See the sample Witap application

- 30,739
- 9
- 69
- 102
-
The `CNCopyCurrentNetworkInfo` sounds promising but I'm having trouble getting it to function properly. What is the interface name for Wifi? I searched for it but came up with no luck. – Charles Vincent Nov 02 '12 at 14:12
-
Is the fact that this may crash in the simulator documented anywhere? It was working perfectly in the simulator for me for weeks, and then suddenly reliably crashing. – Zev Eisenberg Feb 12 '13 at 20:58
The BAD NEWS: 'CNCopyCurrentNetworkInfo' is deprecated: first deprecated in iOS 9.0 - For captive network applications, this has been completely replaced by <NetworkExtension/NEHotspotHelper.h>. For other applications, there is no direct replacement. Please file a bug describing your use of this API to that we can consider your requirements as this situation evolves.
The GOOD NEWS: although deprecated, it still works in iOS 9, AND it has been un-deprecated in iOS 10.
It still works in iOS 13, but only if the app implements Location Services and the user authorizes their usage.

- 1,287
- 1
- 8
- 14