Programmatically auto-connect to WiFi iOS

2019-03-29 23:24发布

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.

3条回答
老娘就宠你
2楼-- · 2019-03-30 00:07

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)
查看更多
倾城 Initia
3楼-- · 2019-03-30 00:30

Not possible unfortunately! Too many issues that Apple would be not okay with. If you're working with a jailbroken device it may be possible (if it's not going on the app store, either)

Here's a question similar to yours you might want to look at

查看更多
闹够了就滚
4楼-- · 2019-03-30 00:30

Quotation from Apple Developer Documentation:

The NEHotspotHelper interface allows an app to participate in the process of joining Wi-Fi/hotspot networks. Such an app is referred to as a Hotspot Helper. A Hotspot Helper receives commands to be processed in the background that allow it to participate in the Hotspot Network state machine.

查看更多
登录 后发表回答