在iPhone上,是否可以查出我们连接的是哪个WIFI网络?
如果是的话,我们还可以获得有关网络配置的其他信息吗?
一种有用的方法是获取当前网络的 SSID。有 API 可以做到这一点吗?
更新:我在这里发现了类似的问题:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试以下方法:
Try following method:
(单独的答案以保留历史记录等)
看起来您可能无法确定您所连接的 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.).
无法发表评论,但这可能是重复的:
通过 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.
您是否查看过 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.