Can the iPhone SDK obtain the Wi-Fi SSID currently connected to?
Asked Answered
S

3

13

In the iPhone SDK I don't see the same SCDynamicStore used on Mac OS X to get the SSID name that your wireless network is currently connected to isn't available.

Is there a way to get the SSID name that the iPhone is currently connected to?

I see some apps do it (Easy Wi-Fi for AT&T for one) but I can't find how it's done in the iPhone SDK docs. A private or unpublish method would be acceptable just as a proof of concept (although I know that likely wouldn't make it to the AppStore).

Santos answered 3/12, 2008 at 23:12 Comment(0)
F
18

This is now possible (iOS 4.1+) via the Captive Network API.

See an example of how to use it on this similar question.

This is not a private API.

Fauman answered 13/6, 2012 at 10:29 Comment(0)
S
6

After digging around I found the anser to this. There are unpublished APIs in the Preferences framework. For examples of this one can look at the Stumbler code hosted on Google Code.

I filed a radar with Apple (#6407431/OpenRadar version) that was marked as a duplicate of #5814810). If you want this officially supported then please also file a radar at bugreport.apple.com.

Update: The above Stumbler code is for 1.x revision iPhone OS SDK. For iPhone OS 2.0 and beyond developers will have to look in PrivateFrameworks/Apple80211.Framework and all that implies.

Santos answered 17/12, 2008 at 21:15 Comment(0)
A
4

Try this code,

#import <SystemConfiguration/CaptiveNetwork.h>

CFArrayRef myArray = CNCopySupportedInterfaces();
CFDictionaryRef myDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));
NSDictionary *ssidList = (__bridge NSDictionary*)myDict;
NSString *SSID = [ssidList valueForKey:@"SSID"];
Ascanius answered 28/11, 2014 at 15:23 Comment(1)
Noting that you'll need a null check on myArrayEweneck

© 2022 - 2024 — McMap. All rights reserved.