iPhone get a list of all SSIDs without private library
Without the use of private library (Apple80211
) you can only get the SSID of the network your device is currently connected to.
iPhone get SSID without private library
As of iOS 7 or 8, you can do this (need Entitlement for iOS 12+ as shown below):
@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;
}
Example output:
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>;
}
Note that no ifs are supported on the simulator. Test on your device.
iOS 12
You must enable access wifi info from capabilities.
Important
To use this function in iOS 12 and later, enable the Access WiFi Information capability for your app in Xcode. When you enable this capability, Xcode automatically adds the Access WiFi Information entitlement to your entitlements file and App ID. Documentation link
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
}
How get a list of networks SSIDs, which is able for Device in search moment?
Looks like, you cannot simply access that info using Captive network Api's. You can get the details of the wifi your device is currently connected to using CNCopyCurrentNetworkInfo
you can get ssid details using NEHotspotHelper in Network Extension, but you need to get access from Apple before using NEHotspotHelper.
Using NEHotspotHelperCommandType =>
FilterScanList(Filter the Wi-Fi scan list) and Evaluate(Evaluate the network). you can get all available NEHotspotNetwork(whcih will contain ssid, bssid, and signalStrength) after registeration is successful
Reference : https://stackoverflow.com/a/39189063/1741121
How to get bssid in iPhone without private library?
I did it this way:
NSArray* interfaces = (NSArray*) CNCopySupportedInterfaces();
for (NSString* interface in interfaces)
{
CFDictionaryRef networkDetails = CNCopyCurrentNetworkInfo((CFStringRef) interface);
if (networkDetails)
{
NSLog(@"all details: %@", (NSDictionary *)networkDetails);
NSLog(@"BSSID: %@", (NSString *)CFDictionaryGetValue (networkDetails, kCNNetworkInfoKeyBSSID));
BSSID1 = (NSString *)CFDictionaryGetValue (networkDetails, kCNNetworkInfoKeyBSSID);
BSSID = [[BSSID1 stringByReplacingOccurrencesOfString:@":"
withString:@""] uppercaseString];
NSLog(@"%@",BSSID);
CFRelease(networkDetails);
}
}
iOS Get list of all WiFi networks
This might be possible with NetworkExtension (available since iOS 8). But you need the com.apple.developer.networking.HotspotHelper
-entitlement in you app to use these APIs. To get these entitlement, you have to contact Apple and describe, why you need it.
I haven't found any code examples, but maybe the documentation of NetworkExtension
helps you.
iPhone check if a particular SSID is available
Nothing has really changed on this in the last year since the previous answer you've found. I work on the Enterprise side of the fence so I luckily don't have to worry about private APIs affecting my apps. It all boils down to Apple not wanting to allow developers to do sleeve things behind the end-users' backs.
To answer your question directly, no, you can't programmatically determine WiFi networks in range without the use of Private APIs. Sorry.
IOS get list of wifi networks available
You can do this with abilities of the system, but you can't publish it on the appstore because it is private api.
Related Topics
How to Parse Json Response from Alamofire API in Swift
Save Custom Objects into Nsuserdefaults
How to Use Facebook iOS Sdk on iOS 10
How to Create Local Notifications
How to Use Protocol as Associatedtype in Another Protocol in Swift
How to Mimic the Bottom Sheet from the Maps App
Xcode 7 Error: "Missing iOS Distribution Signing Identity For ..."
@Property Retain, Assign, Copy, Nonatomic in Objective-C
How to Convert an Nsstring Value to Nsdata
What Kind of Leaks Does Automatic Reference Counting in Objective-C Not Prevent or Minimize
Ios App With Arc, Find Who Is Owner of an Object
Nslog on Devices in iOS 10/Xcode 8 Seems to Truncate - Why
How to Change the Device Orientation Programmatically in iOS 6
Swift Native Functions to Have Numbers as Hex Strings
Resize Uiimage With Aspect Ratio
Best Way to Check If Uitableviewcell Is Completely Visible