不推荐使用 CaptiveNetwork 并且已阻止对 Wifi 名称的调用后,如何在 iOS9 中获取 Wifi SSID [英] How to get Wifi SSID in iOS9 after CaptiveNetwork is deprecated and calls for Wifi name are already blocked

查看:28
本文介绍了不推荐使用 CaptiveNetwork 并且已阻止对 Wifi 名称的调用后,如何在 iOS9 中获取 Wifi SSID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

直到今天,我使用 CaptiveNetwork 接口来显示当前连接的 Wifi 的名称.iOS 9 预发布参考已经说明,CaptiveNetwork 方法现在已弃用,但它们在开始时仍然有效.

Until today I used the CaptiveNetwork Interface to display the name of the currently connected Wifi. The iOS 9 Prerelease reference already stated, that the CaptiveNetwork methods are depracted now, but they still worked at the beginning.

在最新版本中,Apple 似乎已经阻止了此调用(可能是出于隐私问题?).

With the newest version Apple seems to have blocked this calls already (maybe due to privacy concerns?).

是否有其他方法可以获取当前 Wifi 的名称?

Is there any other way to get the name of the current Wifi?

这就是我直到今天获得 SSID 的方式,但你现在只得到零:

This is how I obtained the SSID until today, but you only get nil now:

#import <SystemConfiguration/CaptiveNetwork.h>

NSString *wifiName = nil;  
NSArray *interFaceNames = (__bridge_transfer id)CNCopySupportedInterfaces(); 

for (NSString *name in interFaceNames) { 
    NSDictionary *info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)name); 

    if (info[@"SSID"]) { 
        wifiName = info[@"SSID"]; 
    } 
} 

推荐答案

在 iOS 9 的 GM 中,似乎再次启用了此功能.事实上,它甚至没有在在线文档中列为已弃用,但是 CaptiveNetwork 头文件确实具有以下内容:

In the GM for iOS 9, it seems like this is enabled again. In fact, it's not even listed as deprecated in the online documentation, however the CaptiveNetwork header file does have the following:

CNCopySupportedInterfaces (void) __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_8, __MAC_NA, __IPHONE_4_1, __IPHONE_9_0, CN_DEPRECATION_NOTICE);

所以,它可以在 iOS 9 GM 中运行,但不确定能持续多久 :)

So, it is working in the iOS 9 GM, but not sure for how long :)

这篇关于不推荐使用 CaptiveNetwork 并且已阻止对 Wifi 名称的调用后,如何在 iOS9 中获取 Wifi SSID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆