简体   繁体   中英

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

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 (eg "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

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

A bug-report is already filed to Apple.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM