在iPhone上,是否可以查出我们连接的是哪个WIFI网络?

发布于 2024-08-29 12:23:14 字数 264 浏览 6 评论 0原文

如果是的话,我们还可以获得有关网络配置的其他信息吗?

一种有用的方法是获取当前网络的 SSID。有 API 可以做到这一点吗?

更新:我在这里发现了类似的问题:

iPhone SDK能否获取当前连接的Wi-Fi SSID?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

此生挚爱伱 2024-09-05 12:23:14

尝试以下方法:

#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);

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);
百变从容 2024-09-05 12:23:14

(单独的答案以保留历史记录等)

看起来您可能无法确定您所连接的 WLAN 的 SSID,至少在将进入 App Store 的应用程序中是这样。 这些人使用私有 API - Preferences.framework - 来获取详细信息WLAN(例如“它是隐藏的吗?”“名称是什么?”等)。

(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.).

盗梦空间 2024-09-05 12:23:14

无法发表评论,但这可能是重复的:

通过 SDK 访问 iPhone WiFi 信息

答案似乎是否定的。我对此进行了自己的研究,但无法找到支持的获取 SSID 的方法。

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.

水染的天色ゝ 2024-09-05 12:23:14

您是否查看过 Reachability 示例应用?

编辑:Reachability 应用程序演示了如何使用 SystemConfiguration 框架来显示您的手机是否已连接到互联网,如果已连接,则如何连接。

它还允许您区分本地 WiFi 连接和非 (+[ReachabilityreachabilityForLocalWiFi])。

关于你的问题的实质,你必须查阅手机的 ARP 表。 此答案向您展示了如何做到这一点。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文