如何获取Wifi SSID在iOS9后CaptiveNetwork已弃用,并呼叫Wifi名称已被阻止 [英] How to get Wifi SSID in iOS9 after CaptiveNetwork is deprecated and calls for Wifi name are already blocked

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

问题描述

直到今天,我使用CaptiveNetwork接口显示当前连接的Wifi的名称。
iOS 9预发布引用已经说明,CaptiveNetwork方法现在已经被删除了,但是它们仍然在开始工作。



使用最新版本苹果似乎已阻止此通话(可能是由于隐私问题?)



有没有其他方法获取当前Wifi的名称?



这是我直到今天才获得SSID,但是现在只有nil:

  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];
}
}


解决方案

GM为iOS 9,似乎这个是再次启用。事实上,它甚至没有在在线文档中被列为不推荐使用,但CaptiveNetwork头文件确实有以下:

  CNCopySupportedInterfaces void)__OSX_AVAILABLE_BUT_DEPRECATED_MSG(__ MAC_10_8,__MAC_NA,__IPHONE_4_1,__IPHONE_9_0,CN_DEPRECATION_NOTICE); 

所以,它是在iOS 9 GM,但不知道多长时间:)


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.

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

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

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"]; 
    } 
} 

解决方案

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

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

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

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