能否获取系统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 都必须执行相关代码,且手机系统会自动再次弹窗。此特性与是否开启“单次有效”参数无关。