> For AI agents: the complete documentation index is available at /apps-plugin/docs/llms.txt, the full documentation bundle is available at /apps-plugin/docs/llms-full.txt.

# setWifiList

设置 Wi-Fi 预设列表（iOS 特有）。

## 扫码预览

![扫码预览 setWifiList](https://api.qrserver.com/v1/create-qr-code/?size=200x200\&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fwifi-list%252Findex)

## 使用限制

> \[!WARNING]
> **Android**：豆包 Android 的 setWifiList 固定返回失败（setWifiList is iOS only）；Android 上调用无法设置预设列表。

## 支持版本

前端库版本不低于 `0.0.25`。

## 支持平台

<table>
<thead>
<tr><th>平台</th><th>支持情况</th></tr>
</thead>
<tbody>
<tr><td>Android</td><td>不支持</td></tr>
<tr><td>iOS</td><td>支持</td></tr>
<tr><td>PC</td><td>不支持</td></tr>
<tr><td>HarmonyOS</td><td>不支持</td></tr>
</tbody>
</table>

## 支持场景

<table>
<thead>
<tr><th>场景</th><th>支持情况</th></tr>
</thead>
<tbody>
<tr><td>页面</td><td>支持</td></tr>
<tr><td>卡片</td><td>不支持</td></tr>
</tbody>
</table>

## 接入准备

### 前置条件

- **iOS**：需先调用 startWifi 完成初始化

## 使用说明

该接口为 iOS 特有，用于预设 Wi-Fi 列表。Android 不支持该能力，调用会失败。

- **Android**：该 API 在 Android 上不可用，调用会返回失败

## 调用方式

### 异步 API

```typescript
setWifiList(params: SetWifiListParams): Promise<object>
```

## 入参

<table>
<thead>
<tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
</thead>
<tbody>
<tr><td><code>wifiList</code></td><td><code>WifiListItem[]</code></td><td>是</td><td>-</td><td>-</td><td>预设的 Wi-Fi 列表。</td></tr>
<tr><td><code>wifiList[].bssid</code></td><td><code>string</code></td><td>否</td><td><code>-</code></td><td>-</td><td>Wi-Fi BSSID。</td></tr>
<tr><td><code>wifiList[].password</code></td><td><code>string</code></td><td>否</td><td><code>-</code></td><td>-</td><td>Wi-Fi 密码。</td></tr>
<tr><td><code>wifiList[].ssid</code></td><td><code>string</code></td><td>否</td><td><code>-</code></td><td>-</td><td>Wi-Fi SSID。</td></tr>
</tbody>
</table>

## 调用示例

```typescript
import { setWifiList } from '@doubao-dev/framework/api';

await setWifiList({
  wifiList: [{ ssid: 'Office-WiFi', password: 'password' }]
});
```

## 成功返回

无返回字段。

### 返回示例

```json
{}
```

## 错误处理

错误对象和通用错误码见 [通用错误处理](/apps-plugin/docs/js-api/common-errors.md#错误返回)。

### 失败示例

```json
{
  "errNo": 1401001,
  "errMsg": "wifi is not initialized"
}
```

### 错误码

<table>
<thead>
<tr><th>errNo</th><th>errMsg</th><th>平台</th><th>触发条件</th><th>处理建议</th></tr>
</thead>
<tbody>
<tr><td><code>103</code></td><td><code>feature not support</code></td><td>Android</td><td>该 API 为 iOS 特有，Android 调用固定失败</td><td>不要在 Android 调用该 API</td></tr>
<tr><td><code>1401001</code></td><td><code>wifi is not initialized</code></td><td>iOS</td><td>调用前未先调用 startWifi 完成初始化</td><td>先调用 startWifi 再设置预设列表</td></tr>
</tbody>
</table>

#### 通用错误码

<table>
<thead>
<tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
</thead>
<tbody>
<tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>iOS</td></tr>
</tbody>
</table>

## 平台差异

- **Android**：固定返回 103（该能力仅 iOS）；iOS 未初始化返回 1401001，其他失败统一返回 102。
