时间:2019-05-03 来源:小程序工厂
请告知, connectWifi success 回调触发的时候, 多久才能真正连上wifi(不要欺骗开发者)
===============================iOS上,connectWifi 是调用系统发起连接 WiFi 请求行为,返回的是发起这个行为的结果。连接上 WiFi 的耗时,取决于你的手机与你的路由器之间连接的速度,不同设备是不一样的。之前我一般建议开发者,调用 connectWifi 后,监听 onWiFiConnected 事件看是否能成功,并加一个超时的 timeout 来判定连接失败事件。如果是以 (不要欺骗开发者) 的角度来讲,我也不理解我们有什么理由要欺骗开发者,微信小程序硬件相关接口都是尽可能系统 api 的调用与返回结果的,尽可能不因为微信小程序中间层的封装问题导致硬件开发者的开发不便。
另附 iOS 系统对于 connectWifi 有可能返回的错误情况,有兴趣可以看看。
* @const NEHotspotConfigurationErrorInvalid The Wi-Fi configuration is invalid
* @const NEHotspotConfigurationErrorInvalidSSID The given SSID string is invalid.
* @const NEHotspotConfigurationErrorInvalidWPAPassphrase The given WPA/WPA2 Personal passphrase is invalid.
* @const NEHotspotConfigurationErrorInvalidWEPPassphrase The given WEP passphrase is invalid.
* @const NEHotspotConfigurationErrorInvalidEAPSettings Invalid EAP Settings.
* @const NEHotspotConfigurationErrorInvalidHS20Settings Invalid Hotspot 2.0 Settings.
* @const NEHotspotConfigurationErrorInvalidHS20DomainName The given Hotspot 2.0 domain name is invalid.
* @const NEHotspotConfigurationErrorUserDenied Failed to get the user's approval to add a new configuration.
* @const NEHotspotConfigurationErrorInternal An internal error was encountered.
* @const NEHotspotConfigurationErrorPending Previous request by the calling application is pending.
* @const NEHotspotConfigurationErrorSystemConfiguration The calling application cannot modify the System(MDM/Carrier) configuration.
* @const NEHotspotConfigurationErrorUnknown An unknown configuration error occurred.
* @const NEHotspotConfigurationErrorJoinOnceNotSupported JoinOnce option is not support for EAP configuration.
* @const NEHotspotConfigurationErrorAlreadyAssociated Wi-Fi is already associated.
* @const NEHotspotConfigurationErrorApplicationIsNotInForeground The application is not in the foreground.