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"]; } }
How to find SSID on iOS: Go to Settings > Wi-Fi. The network name (SSID) you are connected to will have a check mark next to it.
Register your app as Hotspot helper.
#import <NetworkExtension/NetworkExtension.h> NSArray * networkInterfaces = [NEHotspotHelper supportedNetworkInterfaces]; NSLog(@"Networks %@",networkInterfaces);
UPDATE (Sept. 11th, 2015)
The following Captive Network APIs have been re-enabled in the latest version of iOS 9 instead.
UPDATE (Sept. 16th, 2015)
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:
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.
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 :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With