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

# getSetting

获取用户当前的应用授权设置。

## 扫码预览

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

## 支持版本

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

## 支持平台

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

## 使用说明

- authSetting 只表示当前应用插件的 scope 授权，不表示操作系统权限；HealthKit 逐类型系统状态通过 getAppAuthorizeSetting 查询。
- authSetting 只包含已向用户请求过且状态明确的权限；豆包当前不支持订阅模板，不要传入 withSubscriptions: true。

## 调用方式

### 异步 API

```typescript
getSetting(params?: GetSettingParams): Promise<GetSettingResult>
```

## 入参

<table>
<thead>
<tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
</thead>
<tbody>
<tr><td><code>withSubscriptions</code></td><td><code>false</code></td><td>否</td><td><code>false</code></td><td>豆包 Android、iOS 当前不支持订阅模板，仅支持 false</td><td>是否同时获取用户订阅消息的订阅状态；当前仅支持 false。</td></tr>
</tbody>
</table>

## 调用示例

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

const result = await getSetting();
console.log(result.authSetting['scope.userLocation']);
```

## 成功返回

<table>
<thead>
<tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
</thead>
<tbody>
<tr><td><code>authSetting</code></td><td><code>AuthSetting</code></td><td>是</td><td>用户授权结果，key 为权限 scope，value 表示是否已授权</td></tr>
<tr><td><code>subscriptionsSetting</code></td><td><code>SubscriptionsSetting</code></td><td>否</td><td>预留的订阅消息设置字段。豆包当前仅支持 `withSubscriptions: false`，因此不会返回该字段。</td></tr>
<tr><td><code>subscriptionsSetting.itemSettings</code></td><td><code>Record&lt;string, SubscriptionSettingStatus&gt;</code></td><td>否</td><td>一次性订阅消息模板的订阅状态</td></tr>
<tr><td><code>subscriptionsSetting.mainSwitch</code></td><td><code>boolean</code></td><td>否</td><td>设置页订阅消息总开关</td></tr>
<tr><td><code>subscriptionsSetting.templateSettings</code></td><td><code>Record&lt;string, SubscriptionTemplateSetting&gt;</code></td><td>否</td><td>模板订阅状态</td></tr>
</tbody>
</table>

### 返回示例

```json
{
  "authSetting": {
    "scope.userLocation": true,
    "scope.record": false
  }
}
```

## 错误处理

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

### 失败示例

```json
{
  "errNo": 103,
  "errMsg": "feature not support"
}
```

### 错误码

<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、iOS</td><td>传入 withSubscriptions: true，豆包当前不支持订阅消息模板</td><td>不要传入 withSubscriptions: true，仅使用默认的 false</td></tr>
<tr><td><code>116</code></td><td><code>resource not found</code></td><td>Android</td><td>豆包未找到当前应用插件</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、iOS</td></tr>
</tbody>
</table>

## 平台差异

- **iOS**：iOS 不返回 errNo 116（resource not found），相应失败场景统一以 errNo 102（internal error）返回。
