For the complete documentation index, see llms.txt. This page is also available as Markdown.

requestPermission

함수형 API requestPermission으로도 같은 기능을 쓸 수 있어요.

기능 설명

권한을 요청해요. 아직 결정되지 않은(notDetermined) 권한이면 사용자에게 권한 요청을 노출하고, 이미 결정된 권한이면 결정된 상태를 그대로 반환해요. 결과는 항상 allowed 또는 denied예요.

타입

requestPermission(permission: { name: PermissionName; access: PermissionAccess }): Promise<Exclude<PermissionStatus, "notDetermined">>;

Params

type PermissionName =
  "clipboard" | "contacts" | "photos" | "geolocation" | "camera" | "microphone";

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

Response

type PermissionStatus = "notDetermined" | "denied" | "allowed";
// 요청 결과는 notDetermined를 제외한 "allowed" | "denied" 중 하나예요.

예시 코드

import { Permissions } from "@apps-in-toss/web-framework";

const status = await requestPermission({ name: "camera", access: "access" });

if (status === "allowed") {
  console.log("카메라 권한이 허용됐어요.");
}

도움이 되었나요?