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.
Type
(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
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
API | WeChat Mini-Program | H5 | React Native |
---|---|---|---|
Taro.setWifiList | ✔️ |