On the iPhone, is it possible to find out which WIFI network we are connected to?

99封情书 提交于 2019-11-29 14:50:22

问题


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?


回答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.).




回答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);



回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/2637094/on-the-iphone-is-it-possible-to-find-out-which-wifi-network-we-are-connected-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!