Skip to main content
Version: 3.x

Taro.setWifiList(option)

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

(option: Option) => Promise<WifiError>

Parameters

Option

PropertyTypeRequiredDescription
wifiListWifiData[]YesProvides a list of preset information of the Wi-Fi network
complete(res: any) => voidNoThe callback function used when the API call completed (always executed whether the call succeeds or fails)
fail(res: any) => voidNoThe callback function for a failed API call
success(res: Result) => voidNoThe callback function for a successful API call

WifiData

object.wifiList is composed as follows

PropertyTypeRequiredDescription
BSSIDstringNoThe SSID of the Wi-Fi network
SSIDstringNoThe BSSID of the Wi-Fi network
passwordstringNoThe password of the Wi-Fi device

Sample Code

Taro.onGetWifiList(function (res) {
if (res.wifiList.length) {
Taro.setWifiList({
wifiList: [{
SSID: res.wifiList[0].SSID,
BSSID: res.wifiList[0].BSSID,
password: '123456'
}]
})
} else {
Taro.setWifiList({
wifiList: []
})
}
})
Taro.getWifiList()

API Support

APIWeChat Mini-ProgramH5React Native
Taro.setWifiList✔️