> 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.

# showToast

显示 Toast 提示。

## 扫码预览

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

## 使用限制

> \[!WARNING]
> **Android、iOS**：Android、iOS 均只按 icon/type 渲染内置图标，不加载 customIcon；依赖 customIcon 展示图标的调用不会生效。

## 支持版本

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

## 支持平台

<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>

## 使用说明

Android 默认显示 3000 毫秒，iOS 默认显示 2000 毫秒；需要双端一致时请显式传入 `duration`。

- message 必填，且 type 与 icon 至少传一个；customIcon 当前不会渲染，请通过 icon 使用内置图标。

## 调用方式

### 异步 API

```typescript
showToast(params: ShowToastParams): Promise<object>
```

## 入参

<table>
<thead>
<tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
</thead>
<tbody>
<tr><td><code>customIcon</code></td><td><code>string</code></td><td>否</td><td><code>-</code></td><td>-</td><td>自定义图标的 URL 或 base64 字符串。Android、iOS：Android、iOS 均只按 icon/type 渲染内置图标，不加载 customIcon。</td></tr>
<tr><td><code>duration</code></td><td><code>number</code></td><td>否</td><td><code>Android 3000，iOS 2000</code></td><td>需双端保持一致时请显式传入。</td><td>提示的持续时间，单位毫秒。</td></tr>
<tr><td><code>icon</code></td><td><code>&quot;success&quot; | &quot;error&quot; | &quot;warn&quot;</code></td><td>否</td><td><code>-</code></td><td>-</td><td>图标。</td></tr>
<tr><td><code>message</code></td><td><code>string</code></td><td>是</td><td>-</td><td>-</td><td>提示的内容。</td></tr>
<tr><td><code>type</code></td><td><code>&quot;default&quot; | &quot;success&quot; | &quot;error&quot; | &quot;warning&quot;</code></td><td>否</td><td><code>'default'</code></td><td>-</td><td>Toast 的类型。</td></tr>
</tbody>
</table>

## 调用示例

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

// 显示一个成功的 Toast
showToast({
  message: '操作成功',
  type: 'success',
  icon: 'success',
  duration: 1500
}).then(() => {
  console.log('Toast 显示完毕');
});

// 显示一个错误的 Toast
showToast({
  message: '网络错误',
  type: 'error',
  icon: 'error'
});
```

## 成功返回

无返回字段。

### 返回示例

```json
{}
```

## 错误处理

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

### 失败示例

```json
{
  "errNo": 104,
  "errMsg": "invalid parameter"
}
```

### 错误码

<table>
<thead>
<tr><th>errNo</th><th>errMsg</th><th>平台</th><th>触发条件</th><th>处理建议</th></tr>
</thead>
<tbody>
<tr><td><code>104</code></td><td><code>invalid parameter</code></td><td>Android、iOS</td><td>message 为空；iOS 还会在 icon 取值非法或入参无法解析时返回（type 由前端归一化为合法值，非法 type 场景不会触发）</td><td>修正参数后重试。</td></tr>
<tr><td><code>103</code></td><td><code>feature not support</code></td><td>iOS</td><td>豆包 UIService 未实现，无法展示 Toast</td><td>降级到其他提示方式。</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>Android</td></tr>
</tbody>
</table>

## 平台差异

- **iOS**：参数校验失败统一返回 errNo 104；UIService 缺失时返回 errNo 103。Android 参数校验失败返回 errNo 104，豆包页面运行上下文缺失返回 errNo 102。
