> 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/sdk/domains-api/permissions.md).

# Permissions

디바이스 권한(클립보드·연락처·앨범·카메라·마이크·위치)의 조회·요청 기능과 권한 에러 클래스를 제공해요.

### API 목록

| API                                                                                                                                 | 설명                |
| ----------------------------------------------------------------------------------------------------------------------------------- | ----------------- |
| [`getPermission`](https://developers-apps-in-toss.toss.im/documentation/sdk/domains-api/permissions/getpermission.md)               | 권한의 현재 상태를 조회해요   |
| [`requestPermission`](https://developers-apps-in-toss.toss.im/documentation/sdk/domains-api/permissions/requestpermission.md)       | 권한을 요청하고 결과를 반환해요 |
| [`openPermissionDialog`](https://developers-apps-in-toss.toss.im/documentation/sdk/domains-api/permissions/openpermissiondialog.md) | 권한 설정 다이얼로그를 띄워요  |

권한 에러 클래스 7종(`OpenCameraPermissionError` 등)도 함께 제공해요. 권한이 필요한 API를 호출했을 때 권한이 거부되면 이 클래스의 인스턴스를 에러로 던져요.

### PermissionError

#### 기능 설명

권한 에러의 공통 부모 클래스예요. 여러 권한 에러를 한 번에 처리할 때 `error instanceof PermissionError`로 확인할 수 있어요. `name`은 `` `${methodName} permission error` `` 형식이에요.

#### 타입

**Params**

```ts
interface PermissionErrorConstructorParams {
  methodName: PermissionFunctionName;
  message: string;
}
```

**Response**

```ts
class PermissionError extends Error {
  name: string; // `${methodName} permission error`
  message: string;
}
```

#### 예시 코드

```js
import { Clipboard, PermissionError } from "@apps-in-toss/web-framework";

try {
  const text = await Clipboard.getText();
  console.log(text);
} catch (error) {
  if (error instanceof PermissionError) {
    console.warn("권한이 거부되었어요:", error.message);
    return;
  }
  console.error(error);
}
```

### GetClipboardTextPermissionError

#### 기능 설명

클립보드 읽기 권한이 거부되었을 때 발생하는 에러예요. `error instanceof GetClipboardTextPermissionError`로 확인할 수 있어요. `PermissionError`를 상속해요.

#### 타입

```ts
class GetClipboardTextPermissionError extends PermissionError {
  name: "getClipboardText permission error";
  message: "클립보드 읽기 권한이 거부되었어요.";
}
```

#### 예시 코드

```js
import {
  Clipboard,
  GetClipboardTextPermissionError,
} from "@apps-in-toss/web-framework";

try {
  const text = await Clipboard.getText();
  console.log(text);
} catch (error) {
  if (error instanceof GetClipboardTextPermissionError) {
    console.warn("클립보드 읽기 권한이 없어요.");
  }
}
```

### SetClipboardTextPermissionError

#### 기능 설명

클립보드 쓰기 권한이 거부되었을 때 발생하는 에러예요. `error instanceof SetClipboardTextPermissionError`로 확인할 수 있어요. `PermissionError`를 상속해요.

#### 타입

```ts
class SetClipboardTextPermissionError extends PermissionError {
  name: "setClipboardText permission error";
  message: "클립보드 쓰기 권한이 거부되었어요.";
}
```

#### 예시 코드

```js
import {
  Clipboard,
  SetClipboardTextPermissionError,
} from "@apps-in-toss/web-framework";

try {
  await Clipboard.setText("복사할 텍스트");
} catch (error) {
  if (error instanceof SetClipboardTextPermissionError) {
    console.warn("클립보드 쓰기 권한이 없어요.");
  }
}
```

### FetchContactsPermissionError

#### 기능 설명

연락처 권한이 거부되었을 때 발생하는 에러예요. `error instanceof FetchContactsPermissionError`로 확인할 수 있어요. `PermissionError`를 상속해요.

#### 타입

```ts
class FetchContactsPermissionError extends PermissionError {
  name: "fetchContacts permission error";
  message: "연락처 권한이 거부되었어요.";
}
```

#### 예시 코드

```js
import {
  Device,
  FetchContactsPermissionError,
} from "@apps-in-toss/web-framework";

try {
  const contacts = await Device.getContacts({ size: 10, offset: 0 });
  console.log(contacts);
} catch (error) {
  if (error instanceof FetchContactsPermissionError) {
    console.warn("연락처 권한이 없어요.");
  }
}
```

### FetchAlbumPhotosPermissionError

#### 기능 설명

사진첩 권한이 거부되었을 때 발생하는 에러예요. `error instanceof FetchAlbumPhotosPermissionError`로 확인할 수 있어요. `PermissionError`를 상속해요.

#### 타입

```ts
class FetchAlbumPhotosPermissionError extends PermissionError {
  name: "fetchAlbumPhotos permission error";
  message: "사진첩 권한이 거부되었어요.";
}
```

#### 예시 코드

```js
import {
  Device,
  FetchAlbumPhotosPermissionError,
} from "@apps-in-toss/web-framework";

try {
  const photos = await Device.getPhotos();
  console.log(photos);
} catch (error) {
  if (error instanceof FetchAlbumPhotosPermissionError) {
    console.warn("사진첩 권한이 없어요.");
  }
}
```

### GetCurrentLocationPermissionError

#### 기능 설명

위치 권한이 거부되었을 때 발생하는 에러예요. `error instanceof GetCurrentLocationPermissionError`로 확인할 수 있어요. `PermissionError`를 상속해요.

#### 타입

```ts
class GetCurrentLocationPermissionError extends PermissionError {
  name: "getCurrentLocation permission error";
  message: "위치 권한이 거부되었어요.";
}
```

#### 예시 코드

```js
import {
  Accuracy,
  Device,
  GetCurrentLocationPermissionError,
} from "@apps-in-toss/web-framework";

try {
  const location = await Device.getLocation({ accuracy: Accuracy.Balanced });
  console.log(location);
} catch (error) {
  if (error instanceof GetCurrentLocationPermissionError) {
    console.warn("위치 권한이 없어요.");
  }
}
```

### StartUpdateLocationPermissionError

#### 기능 설명

위치 업데이트 권한이 거부되었을 때 발생하는 에러예요. `GetCurrentLocationPermissionError`와 같은 클래스를 가리키는 별칭이라서 `error instanceof StartUpdateLocationPermissionError`는 `GetCurrentLocationPermissionError` 인스턴스에도 `true`예요.

#### 타입

```ts
const StartUpdateLocationPermissionError = GetCurrentLocationPermissionError;
```

#### 예시 코드

```js
import {
  Accuracy,
  Device,
  StartUpdateLocationPermissionError,
} from "@apps-in-toss/web-framework";

const cleanup = Device.subscribeLocation({
  options: {
    accuracy: Accuracy.Balanced,
    timeInterval: 3000,
    distanceInterval: 10,
  },
  onEvent: (location) => {
    console.log(location);
  },
  onError: (error) => {
    if (error instanceof StartUpdateLocationPermissionError) {
      console.warn("위치 권한이 없어요.");
    }
    cleanup();
  },
});
```

### OpenCameraPermissionError

#### 기능 설명

카메라 권한이 거부되었을 때 발생하는 에러예요. `error instanceof OpenCameraPermissionError`로 확인할 수 있어요. `PermissionError`를 상속해요.

#### 타입

```ts
class OpenCameraPermissionError extends PermissionError {
  name: "openCamera permission error";
  message: "카메라 권한이 거부되었어요.";
}
```

#### 예시 코드

```js
import { Device, OpenCameraPermissionError } from "@apps-in-toss/web-framework";

try {
  const image = await Device.openCamera();
  console.log(image);
} catch (error) {
  if (error instanceof OpenCameraPermissionError) {
    console.warn("카메라 권한이 없어요.");
  }
}
```

### PermissionName

#### 기능 설명

권한을 식별하는 이름 타입이에요.

#### 타입

```ts
type PermissionName =
  | "clipboard" // 클립보드
  | "contacts" // 연락처
  | "photos" // 사진첩
  | "geolocation" // 위치
  | "camera" // 카메라
  | "microphone"; // 마이크
```

### PermissionAccess

#### 기능 설명

권한의 접근 종류 타입이에요. `read`/`write`는 클립보드·연락처·사진첩처럼 읽기/쓰기가 구분되는 권한에, `access`는 위치·카메라·마이크처럼 구분이 없는 권한에 사용해요.

#### 타입

```ts
type PermissionAccess = "read" | "write" | "access";
```

### PermissionStatus

#### 기능 설명

권한의 상태 타입이에요. `notDetermined`는 사용자가 아직 권한 요청에 응답하지 않은 상태예요.

#### 타입

```ts
type PermissionStatus = "notDetermined" | "denied" | "allowed";
```

### PermissionFunctionName

#### 기능 설명

권한 에러가 발생하는 함수 이름 타입이에요. `PermissionError`의 `name`을 구성할 때 사용해요.

#### 타입

```ts
type PermissionFunctionName =
  | "getClipboardText"
  | "setClipboardText"
  | "fetchContacts"
  | "fetchAlbumPhotos"
  | "getCurrentLocation"
  | "openCamera";
```

### PermissionErrorConstructorParams

#### 기능 설명

`PermissionError` 생성자에 전달하는 파라미터 타입이에요.

#### 타입

```ts
interface PermissionErrorConstructorParams {
  methodName: PermissionFunctionName;
  message: string;
}
```

### PermissionErrorType

#### 기능 설명

권한 에러 클래스가 만드는 에러 인스턴스의 형태예요.

#### 타입

```ts
interface PermissionErrorType extends Error {
  name: string;
  message: string;
}
```

### GetPermissionFunction

#### 기능 설명

`withPermission`으로 래핑된 함수에 붙는 `getPermission` 정적 메서드의 시그니처예요.

#### 타입

```ts
type GetPermissionFunction = () => Promise<PermissionStatus>;
```

### PermissionDialogFunction

#### 기능 설명

`withPermission`으로 래핑된 함수에 붙는 `openPermissionDialog` 정적 메서드의 시그니처예요.

#### 타입

```ts
type PermissionDialogFunction = () => Promise<
  Exclude<PermissionStatus, "notDetermined">
>;
```

### PermissionFunctionWithDialog

#### 기능 설명

`withPermission`이 반환하는 함수 타입이에요. 원래 함수 시그니처에 `getPermission`/`openPermissionDialog` 정적 메서드가 더해진 형태예요.

#### 타입

```ts
type PermissionFunctionWithDialog<T extends (...args: any[]) => any> = T & {
  getPermission: GetPermissionFunction;
  openPermissionDialog: PermissionDialogFunction;
};
```


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers-apps-in-toss.toss.im/documentation/sdk/domains-api/permissions.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
