ios 可编程设置wifi热点密码

omqzjyyz  于 9个月前  发布在  iOS
关注(0)|答案(2)|浏览(84)

我想为我的应用程序以编程方式设置我的WiFi热点密码,这样用户就不必去设置菜单检查他们的密码。
我已经在使用NEHotspotNetwork,在那里它设置密码,但在这里,我们需要设置密码,这是已经在设置菜单中连接到网络。
这也是有帮助的,如果我可以得到我的WiFi热点密码,从应用程序没有越狱我的设备。

v09wglhw

v09wglhw1#

你只需要使用以下代码:

WifiConfiguration netConfig = new WifiConfiguration();
netConfig .preSharedKey = "yourpassword";

字符串

brccelvz

brccelvz2#

使用NEHotspotNetwork函数register,您可以设置密码:

NEHotspotHelper.register(options: options, queue: queue) { (cmd: NEHotspotHelperCommand) in
                
                if cmd.commandType == NEHotspotHelperCommandType.filterScanList {
                    //Get all available hotspots
                    var list: [NEHotspotNetwork] = cmd.networkList!
                    //Figure out the hotspot you wish to connect to
                    // let desiredNetwork : NEHotspotNetwork? = getBestScanResult(list)
                    
                    var hotspot = [NEHotspotNetwork]()
                    
                    for network in cmd.networkList!
                    {//check for your network ssid and set password
                          network.setConfidence(.high)
                                    network.setPassword("yourpassword") //Set the WIFI password
                                    
                              
                                hotspot.append(network)
                           
                    }
                    
                    
                    let response = cmd.createResponse(NEHotspotHelperResult.success)
                    response.setNetworkList(hotspot)
                    response.deliver() } else if cmd.commandType == NEHotspotHelperCommandType.evaluate {
                    if let network = cmd.network {
                  
     let response = cmd.createResponse(NEHotspotHelperResult.success)
                        response.setNetwork(network)
                        response.deliver() //Respond back }
                } else if cmd.commandType == NEHotspotHelperCommandType.authenticate {
                    //Perform custom authentication and respond back with success
                    // if all is OK
                    let response = cmd.createResponse(NEHotspotHelperResult.success)
                    response.deliver() //Respond back
                }

字符串
您也可以使用网络配置文件的帮助下,苹果路由器2工具为您的已知网络。
在那里,您需要设置WiFi,然后在设备上安装NCP后,它会自动连接到上述网络。
但是你必须在服务器上托管该文件,因为我们不能在本地下载配置文件,并使用本地服务器,如GCDServer(已经尝试过)。

相关问题