簡體   English   中英

iOS 13:使用新的 NEHotspotConfiguration.init(ssidPrefix: String) 似乎不起作用

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

我目前正在運行 Xcode 11.0 和 iOS 13.1(測試版)。 我正在試驗 iOS 13 中新增的功能,即能夠連接到僅知道前綴的 Wifi 熱點: Apple Docs

這非常適合無頭配件的 Wifi 設置,因為您無需要求用戶切換到操作系統設置即可連接到配件的 wifi。

但不幸的是,我無法使其按預期工作。

我的代碼( 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")
            }
        }
    }

使用全名(例如“device-012”),它可以工作:

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

我錯過了什么嗎? 前綴字符串是否可能需要一些通配符模式?

謝謝,亨利

不設置configuration.joinOnce = true或將其設置為false使其工作。

已向 Apple 提交錯誤報告。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM