以编程方式自动连接到WiFi iOS [英] Programmatically auto-connect to WiFi iOS

查看:83
本文介绍了以编程方式自动连接到WiFi iOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Swift上创建一个应用程序,我需要知道,是否可以通过编程方式自动将iPhone连接到WiFi,并提供该WiFi网络的SSID和密码作为参数.

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.

谢谢.

推荐答案

以下代码将在Xcode 9和iOS 11上运行

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)

这篇关于以编程方式自动连接到WiFi iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆