> For the complete documentation index, see [llms.txt](https://developers-apps-in-toss.toss.im/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers-apps-in-toss.toss.im/documentation/api-and-sdk-zh/common/permission.md).

# 权限

如果要在应用中使用剪贴板、位置信息、相册、联系人等功能，需要设置权限。\
我们将介绍如何设置权限，以便这些功能能在 Toss 应用中使用。

{% hint style="info" %}
**WebView 环境中的 Web API**

在 WebView 环境中不会限制一般 Web API 的使用。\
因此，可以与浏览器中可用的大多数标准 Web API 同样使用。
{% endhint %}

## 权限列表

下面是权限名称和允许的操作列表。也请确认每个权限对应的访问值。

### 相机

* 权限名称： [`camera`](/documentation/api-and-sdk-zh/common/permission/camera.md)
* 访问(`access`): openCamera

### 相册

* 权限名称： [`photos`](/documentation/api-and-sdk-zh/common/permission/album.md)
* 读取(`read`): fetchAlbumPhotos

### 剪贴板

* 权限名称： [`clipboard`](/documentation/api-and-sdk-zh/common/permission/clipboard.md)
* 读取(`read`): getClipboardText
* 写入(`write`): setClipboardText

### 联系人

* 权限名称： [`contacts`](/documentation/api-and-sdk-zh/common/permission/contact.md)
* 读取(`read`): fetchContacts

### 位置

* 权限名称： [`geolocation`](/documentation/api-and-sdk-zh/common/permission/location.md)
* 访问(`access`): startUpdateLocation, getCurrentLocation, useGeolocation

### 麦克风

* 权限名称： `microphone`
* 访问(`access`): 预计后续将支持。如果是 WebView，请使用 Web API 直接实现。

## 设置权限

应用中使用的权限 `granite.config.ts`可定义在……中。这在审核应用时会用到。 [权限列表](#권한-목록)请参考……进行设置。

下面是设置为可使用剪贴板、相机和相册的示例。

{% tabs %}
{% tab title="React Native" %}

```tsx
import { appsInToss } from '@apps-in-toss/framework/plugins';
import { defineConfig } from '@granite-js/react-native/config';

export default defineConfig({
  appName: '<my-service-name>',
  plugins: [
    appsInToss({
      permissions: [
        {
          name: 'clipboard',
          access: 'read',
        },
        {
          name: 'clipboard',
          access: 'write',
        },
        {
          name: 'camera',
          access: 'access',
        },
        {
          name: 'photos',
          access: 'read',
        },
      ],
    }),
  ],
});
```

{% endtab %}

{% tab title="WebView" %}

```tsx
import { defineConfig } from '@apps-in-toss/web-framework/config';

export default defineConfig({
  appName: '<my-service-name>', // 在 Apps in Toss 控制台中设置的应用名称
  web: {
    /* 现有设置 */
  },
  permissions: [
    {
      name: 'clipboard',
      access: 'read',
    },
    {
      name: 'clipboard',
      access: 'write',
    },
    {
      name: 'camera',
      access: 'access',
    },
    {
      name: 'photos',
      access: 'read',
    },
  ],
});
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers-apps-in-toss.toss.im/documentation/api-and-sdk-zh/common/permission.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
