My question is about private API in IOS. Is there some API to manage WiFi connection? For example I\'m using Apple80211.framework to scan WiFi networks but it\'s unusable fo
I ran into this issue last year and after quite a bit of digging I came across a helpful example called SOLStumbler. For this app to work your device must be jailbroken. I modified SOLStumbler and threw up a sample app on github. It uses the IPConfiguration bundle to access Apple80211 framework, which allows you to associate to a network. The readme contains the custom build instructions.
https://github.com/devinshively/wifiAssociate
We can programmatically connect wifi networks after iOS 11 public API. You can connect wifi using SSID and password like following.
Swift
var configuration = NEHotspotConfiguration.init(ssid: "wifi name", passphrase: "wifi password", isWEP: false)
configuration.joinOnce = true
NEHotspotConfigurationManager.shared.apply(configuration) { (error) in
if error != nil {
//an error occurred
print(error?.localizedDescription)
}
else {
//success
}
}
Don't forget import NetworkExtension
.
No need for private API any more! With iOS 11, Apple provided a public API you can use to programmatically join a WiFi network without leaving your app.
The class you’ll need to use is called NEHotspotConfiguration
.
To use it, you need to enable the Hotspot
capability in your App Capabilities (Adding Capabilities). Quick working example :
NEHotspotConfiguration *configuration = [[NEHotspotConfiguration
alloc] initWithSSID:@“SSID”];
configuration.joinOnce = YES;
[[NEHotspotConfigurationManager sharedManager] applyConfiguration:configuration completionHandler:nil];
This will prompt the user to join the “SSID” WiFi network. It will stay connected to the WiFi until the user leaves the app.
This doesn't work with the simulator you need to run this code with an actual device to make it work.
More informations here : https://developer.apple.com/documentation/networkextension/nehotspotconfiguration
It's possible in any version of iOS which can load a configuration profile: the app needs to generate a profile with the desired network credentials, and host a web server which provides the profile to Mobile Safari.