iPhone在没有私有库的情况下获得SSID我有一个商业应用程序,它有一个完全合法的理由来查看它连接到的网络的SSID:如果它连接到一个第三方硬件设备的Adhoc网络,它需要以一种不同于连接到互联网的方式运行。我所看到的有关获得SSID的一切都告诉我,我必须使用Apple80211,据我所知,它是一个私有库。我还读到,如果我使用一个私人图书馆,苹果将不会批准该应用程序。我是被困在一个苹果和一个艰难的地方之间,还是这里缺少什么东西?
3 回答
慕桂英3389331
TA贡献2036条经验 获得超8个赞
@import SystemConfiguration.CaptiveNetwork;/** Returns first non-empty SSID network info dictionary. * @see CNCopyCurrentNetworkInfo */- (NSDictionary *)fetchSSIDInfo{ NSArray *interfaceNames = CFBridgingRelease(CNCopySupportedInterfaces()); NSLog(@"%s: Supported interfaces: %@", __func__, interfaceNames); NSDictionary *SSIDInfo; for (NSString *interfaceName in interfaceNames) { SSIDInfo = CFBridgingRelease( CNCopyCurrentNetworkInfo((__bridge CFStringRef)interfaceName)); NSLog(@"%s: %@ => %@", __func__, interfaceName, SSIDInfo); BOOL isNotEmpty = (SSIDInfo.count > 0); if (isNotEmpty) { break; } } return SSIDInfo;}
2011-03-04 15:32:00.669 ShowSSID[4857:307] -[ShowSSIDAppDelegate fetchSSIDInfo]: Supported interfaces: ( en0)2011-03-04 15:32:00.693 ShowSSID[4857:307] -[ShowSSIDAppDelegate fetchSSIDInfo]: en0 => { BSSID = "ca:fe:ca:fe:ca:fe"; SSID = XXXX; SSIDDATA = <01234567 01234567 01234567>;}
scutil
$ scutil> show State:/Network/Interface/en1/AirPort<dictionary> { Power Status : 1 SecureIBSSEnabled : FALSE BSSID : <data> 0xcafecafecafe SSID_STR : XXXX SSID : <data> 0x012345670123456701234567 Busy : FALSE CHANNEL : <dictionary> { CHANNEL : 1 CHANNEL_FLAGS : 10 }}> exit
IOS 12
在iOS 12及更高版本中使用此功能非常重要,请在Xcode中为您的应用程序启用访问WiFi信息功能。启用此功能时,Xcode会自动将访问WiFi信息权限添加到应享权利文件和应用程序ID中。 文档链接
SWIFT 4.2
func getConnectedWifiInfo() -> [AnyHashable: Any]? { if let ifs = CFBridgingRetain( CNCopySupportedInterfaces()) as? [String], let ifName = ifs.first as CFString?, let info = CFBridgingRetain( CNCopyCurrentNetworkInfo((ifName))) as? [AnyHashable: Any] { return info } return nil}
当年话下
TA贡献1890条经验 获得超9个赞
- (id)fetchSSIDInfo { NSArray *ifs = (__bridge_transfer NSArray *)CNCopySupportedInterfaces(); NSLog(@"Supported interfaces: %@", ifs); NSDictionary *info; for (NSString *ifnam in ifs) { info = (__bridge_transfer NSDictionary *)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam); NSLog(@"%@ => %@", ifnam, info); if (info && [info count]) { break; } } return info;}
- 3 回答
- 0 关注
- 609 浏览
添加回答
举报
0/150
提交
取消