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

# canIUse

检测当前环境是否支持指定 API 或能力。

## 支持版本

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

## 支持平台

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

## 调用方式

### 异步 API

```typescript
canIUse(params: CanIUseParams): Promise<CanIUseResult>
```

## 入参

<table>
<thead>
<tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
</thead>
<tbody>
<tr><td><code>schema</code></td><td><code>string</code></td><td>是</td><td>-</td><td>-</td><td>需要检测的能力标识，例如 API 名称</td></tr>
</tbody>
</table>

## 调用示例

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

const { result } = await canIUse({ schema: 'doubao.getLocation' });
console.log('是否支持 getLocation:', result);
```

## 成功返回

<table>
<thead>
<tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
</thead>
<tbody>
<tr><td><code>result</code></td><td><code>boolean</code></td><td>是</td><td>是否支持所检测的能力</td></tr>
</tbody>
</table>

### 返回示例

```json
{
  "result": true
}
```

## 错误处理

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

### 失败示例

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

### 错误码

<table>
<thead>
<tr><th>errNo</th><th>errMsg</th><th>平台</th><th>触发条件</th><th>处理建议</th></tr>
</thead>
<tbody>
<tr><td><code>600001</code></td><td><code>invalid parameter</code></td><td>Android、iOS</td><td>schema 为空或格式不合法</td><td>传入有效的 schema 字符串，格式为&quot;命名空间.方法名&quot;</td></tr>
</tbody>
</table>
