スタートガイド
インストール手順と、このプラグインの完全なMarkdownガイドを含むセットアッププロンプトをコピーします。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-permissions`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/permissions/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
インストール
「インストール」セクションAIアシストによるセットアップでプラグインをインストールできます。以下のコマンドを使用して、お使いのAIツールに Capgo のスキルを追加してください:
bunx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins次に、以下のプロンプトを使用します:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-permissions` plugin in my project.手動セットアップを希望する場合は、以下のコマンドを実行してプラグインをインストールし、下記のプラットフォーム別の手順に従ってください:
bun add @capgo/capacitor-permissionsbunx cap syncインポート
「インポート」セクションimport { Permissions } from '@capgo/capacitor-permissions';クイックスタート
「クイックスタート」セクションimport { Permissions } from '@capgo/capacitor-permissions';
const { status } = await Permissions.check({ permission: 'camera' });例: request
「例: request」というタイトルのセクションimport { Permissions } from '@capgo/capacitor-permissions';
const { status } = await Permissions.request({ permission: 'notifications' });例: checkMultiple
「例: checkMultiple」というタイトルのセクションimport { Permissions } from '@capgo/capacitor-permissions';
const { statuses } = await Permissions.checkMultiple({ permissions: ['camera', 'microphone'],});よくある落とし穴
「よくある落とし穴」セクション- ネイティブ同期: 実行
bunx cap syncプラグインのアップグレード後。 - 信頼できる情報源: 信頼
src/definitions.tsGitHub リポジトリ内。
プラットフォームのセットアップ
「プラットフォームのセットアップ」セクション- iOSの設定 Info.plistの利用目的(usage strings)について
PermissionName. - Androidの設定 を
uses-permissionエントリおよび minSdk 24。
使い方
「使い方」セクションimport { Permissions } from '@capgo/capacitor-permissions';
export async function ensureCamera(): Promise<boolean> { const { status } = await Permissions.check({ permission: 'camera' }); if (status === 'granted') return true; const { status: afterRequest } = await Permissions.request({ permission: 'camera' }); return afterRequest === 'granted';}ステータスが blockedの場合、ユーザーを設定画面へ誘導します:
await Permissions.openSettings({ type: 'application' });