iOS 13: Using the new NEHotspotConfiguration.init(ssidPrefix: String) does not seem to work

痞子三分冷 提交于 2019-12-10 11:39:17

问题


I am currently running Xcode 11.0 and iOS 13.1 (beta). I am experimenting with the newly added functionality in iOS 13 of being able to connect to Wifi hotspots where only the prefix is known: Apple Docs

This is perfect for headless accessory's Wifi setup, as you would not need to ask the user to switch to the OS settings in order to connect to the accessory's wifi.

But unfortunately I cannot make it work as expected.

My code (Swift 5):

if #available(iOS 13, *) {
        // The accessory's wifi name starts with "device-", followed by 3 digit number, e.g. "device-012"
        let configuration = NEHotspotConfiguration.init(ssidPrefix: "device-")
        configuration.joinOnce = true

        NEHotspotConfigurationManager.shared.apply(configuration) { (error) in
            if error != nil {
                if error?.localizedDescription == "already associated."
                {
                    print("Connected")
                }
                else {
                    print("No Connected")
                }
            }
            else {
                print("Connected")
            }
        }
    }

Using the full name (e.g. "device-012"), it works:

let configuration = NEHotspotConfiguration.init(ssidPrefix: "device-012")

Am I missing something? Does the prefix-string maybe needs some wildcard pattern or so?

Thanks, Henry


回答1:


Not setting configuration.joinOnce = true or setting it to false makes it work.

A bug-report is already filed to Apple.



来源:https://stackoverflow.com/questions/58029300/ios-13-using-the-new-nehotspotconfiguration-initssidprefix-string-does-not-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!