title: Taro.setWifiList(option)

sidebar_label: setWifiList

Sets the information on the AP in wifiList, which is called after the onGetWifiList callback. This API is specific to iOS.

Notes

  • This API can only be called after the onGetWifiList callback.
  • In this case, the app will be suspended and wait for the Mini Program to set the Wi-Fi network’s information. Call the API as soon as possible. If no data is available, pass an empty array.
  • Multiple callbacks with a list of duplicate Wi-Fi devices may be received in a single process as the list of nearby Wi-Fi devices is refreshed.

Reference

Type

  1. (option: Option) => Promise<WifiError>

Parameters

Option

Property Type Required Description
wifiList WifiData[] Yes Provides a list of preset information of the Wi-Fi network
complete (res: any) => void No The callback function used when the API call completed (always executed whether the call succeeds or fails)
fail (res: any) => void No The callback function for a failed API call
success (res: Result) => void No The callback function for a successful API call

WifiData

object.wifiList is composed as follows

Property Type Required Description
BSSID string No The SSID of the Wi-Fi network
SSID string No The BSSID of the Wi-Fi network
password string No The password of the Wi-Fi device

Sample Code

  1. Taro.onGetWifiList(function (res) {
  2. if (res.wifiList.length) {
  3. Taro.setWifiList({
  4. wifiList: [{
  5. SSID: res.wifiList[0].SSID,
  6. BSSID: res.wifiList[0].BSSID,
  7. password: '123456'
  8. }]
  9. })
  10. } else {
  11. Taro.setWifiList({
  12. wifiList: []
  13. })
  14. }
  15. })
  16. Taro.getWifiList()

API Support

API WeChat Mini-Program H5 React Native
Taro.setWifiList ✔️