獲取wifi熱點

https://stackoverflow.com/questions/31555640/how-to-get-wifi-ssid-in-ios9-after-captivenetwork-is-deprecated-and-calls-for-wiios

 

Register your app as Hotspot helper.app

#import <NetworkExtension/NetworkExtension.h>  NSArray * networkInterfaces = [NEHotspotHelper supportedNetworkInterfaces]; NSLog(@"Networks %@",networkInterfaces);

UPDATE (Sept. 11th, 2015)ide

The following Captive Network APIs have been re-enabled in the latest version of iOS 9 instead.this

  • CNCopySupportedInterfaces
  • CNCopyCurrentNetworkInfo

UPDATE (Sept. 16th, 2015)spa

If you still prefer to use NetworkExtension and Apple gave you permission to add the entitlements, then you can do this to get the wifi information:code

for(NEHotspotNetwork *hotspotNetwork in [NEHotspotHelper supportedNetworkInterfaces]) { NSString *ssid = hotspotNetwork.SSID; NSString *bssid = hotspotNetwork.BSSID; BOOL secure = hotspotNetwork.secure; BOOL autoJoined = hotspotNetwork.autoJoined; double signalStrength = hotspotNetwork.signalStrength; }

NetworkExtension provides you some extra information as secure, auto joined or the signal strength. And it also allows you to set credential to wifis on background mode, when the user scans wifis around.orm

相關文章
相關標籤/搜索