能否獲取系統wifi列表信息
不能,只能獲取用戶當前連接的wifi信息
https://developer.apple.com/documentation/systemconfiguration/1614126-cncopycurrentnetworkinfo
能否自動掃描周邊特定wifi名並通過密碼連接
iOS11+ 系統才可以。
通過代碼設置wifi名字和前綴(密碼可根據wifi是否有密碼選不同方法)連接, 測試發現連接所需時間一般在5s以上,並且在wifi遠離等信號較弱時,可能會失敗(unknown/internal error/無法加入網絡)。
代碼可以觸發檢測一次,如果檢測到同名wifi並且密碼一致,系統會自動彈窗供用戶選擇是否加入。
是否自動循環檢測?
不會,但是可以根據回調結果,自定義定時器重新檢測。
連接后有效期
可設置是否單次有效(下次進入app會重新檢測)和有效天數。
單次有效相關:
When joinOnce is set to true, the hotspot remains configured and connected only as long as the app that configured it is running in the foreground. The hotspot is disconnected and its configuration is removed when any of the following events occurs:
The app stays in the background for more than 15 seconds.
The device sleeps.
The app crashes, quits, or is uninstalled.
The app connects the device to a different Wi-Fi network.
The user connects the device to a different Wi-Fi network.
To disconnect the device from a hotspot configured with joinOnce set to true, call removeConfiguration(forSSID:).
手機的 wifi 連接中斷后(比如wifi設備關閉/遠離),當wifi設備打開/靠近,app再次嘗試連接時,是否會再次彈窗請求用戶允許加入
會再次彈窗請求,每次重連 wifi 都必須執行相關代碼,且手機系統會自動再次彈窗。此特性與是否開啟“單次有效”參數無關。