Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically auto-connect to WiFi iOS

I'm creating an app on Swift, and I need to know, if there's any way I can programatically auto connect an iPhone to a WiFi giving as paremeters the SSID and the Password from that WiFi Network.

Thanks in advance.

like image 866
Schavcovsky Avatar asked Feb 24 '16 21:02

Schavcovsky


1 Answers

Below code will work on Xcode 9 and iOS 11

let WiFiConfig = NEHotspotConfiguration(ssid: "Mayur1",
                                                  passphrase: "123456789",
                                                  isWEP: false)

    WiFiConfig.joinOnce = false
    NEHotspotConfigurationManager.shared.apply(WiFiConfig) { error in
        // Handle error or success
        print(error?.localizedDescription)
like image 108
Mayur Rathod Avatar answered Nov 16 '22 06:11

Mayur Rathod