6

If yes, can we also get additional information about the network configuration?

One useful way to do this could be getting the SSID of the current network. Is there an API to do that?

Update: I found a similar question here:

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

Community
  • 1
  • 1
Plumenator
  • 1,682
  • 3
  • 20
  • 49
  • Possible duplicate: http://stackoverflow.com/questions/1625158/iphone-sdk-detect-wifi-and-carrier-network – Frank Shearar Apr 14 '10 at 12:11
  • No, not a duplicate of that. This questioner wants to know *which* WiFi network he's connected to, not *whether* he's connected to one, or whether he's connected via mobile only (or not at all). – T.J. Crowder Apr 14 '10 at 12:16
  • Until a few weeks ago there were an application called WifiTrak (http://www.bitrino.com/wifitrak/support.html) on the appstore which displayed a list of all available wi-fi hotspots in range. It has however been pulled from the appstore, so even though it appeared that this is possible it might not be acceptable by Apple for whatever reason. – Claus Broch Apr 14 '10 at 13:09
  • possible duplicate of http://stackoverflow.com/questions/339089/can-the-iphone-sdk-obtain-the-wi-fi-ssid-currently-connected-to – Brad Larson Apr 18 '10 at 14:52

4 Answers4

2

Try following method:

#import <SystemConfiguration/CaptiveNetwork.h>

NSString *wifiName = @"Not Found";
CFArrayRef myArray = CNCopySupportedInterfaces();

if (myArray != nil) {

    CFDictionaryRef myDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));

    if (myDict != nil) {
        NSDictionary *dict = (NSDictionary*)CFBridgingRelease(myDict);

        wifiName = [dict valueForKey:@"SSID"];

    }  
}

NSLog(@"wifiName:%@", wifiName);
nhahtdh
  • 55,989
  • 15
  • 126
  • 162
Paradise
  • 558
  • 6
  • 17
1

(Separate answer to preserve history etc.)

It looks like you might not be able to determine the SSID of the WLAN to which you're connected, at least in an app that will go into the App Store. These people use a private API - Preferences.framework - to get to the details of the WLAN (like "is it hidden?" "What's the name?" etc.).

Frank Shearar
  • 17,012
  • 8
  • 67
  • 94
1

Can't comment, but this might be a duplicate:

Accessing iPhone WiFi Information via SDK

Answer seems to be no. I've done my own research on this and have been unable to find a supported way of getting the SSID.

Community
  • 1
  • 1
Gordon Christie
  • 609
  • 5
  • 12
0

Have you looked at the Reachability sample app?

Edit: The Reachability app demonstrates the use of the SystemConfiguration framework to show whether your phone's connected to the internet and, if so, how.

It further allows you to distinguish between a local WiFi connection and not (+[Reachability reachabilityForLocalWiFi]).

Regarding the meat of your question, you'll have to consult the phone's ARP table. This answer shows you how to do just that.

Community
  • 1
  • 1
Frank Shearar
  • 17,012
  • 8
  • 67
  • 94
  • Perhaps you could clarify your answer. Are you saying "yes, you can, here's a link to some sample code that does it" or are you saying "no, you can't; but here's an idea of the other things you can do." Or are you saying "I don't know either, but look over here" which really would be better as a comment, as it doesn't answer the question. – T.J. Crowder Apr 14 '10 at 12:07
  • The reachability sample only demonstrates detecting IF we are connected to a network. It does not show how we can get the current network's identification. – Plumenator Apr 14 '10 at 12:09
  • What do you mean by a network's identification? Do you mean the SSID of a WLAN? – Frank Shearar Apr 14 '10 at 13:00
  • Well, I wasn't sure what I wanted when I asked the question. But on some thought, yes, the SSID. – Plumenator Apr 14 '10 at 13:10