スタートガイド
インストール手順と、このプラグインの完全なMarkdownガイドを含むセットアッププロンプトをコピーします。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-flash`
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/flash/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 のスキルを追加してください:
npx 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-flash` plugin in my project.手動セットアップを希望する場合は、以下のコマンドを実行してプラグインをインストールし、下記のプラットフォーム別の手順に従ってください:
bun add @capgo/capacitor-flashbunx cap syncインポート
「インポート」セクションimport { CapacitorFlash } from '@capgo/capacitor-flash';クイックスタート
「クイックスタート」セクションimport { CapacitorFlash } from '@capgo/capacitor-flash';
const { value: available } = await CapacitorFlash.isAvailable();if (!available) { toast('No flashlight on this device'); return;}await CapacitorFlash.switchOn({ intensity: 0.5 });例:QRスキャナーのコンパニオン
「例:QRスキャナー用コンパニオン」セクションawait CapacitorFlash.switchOn({ intensity: 1 });const code = await scanFrame();await CapacitorFlash.switchOff();よくある落とし穴
「よくある落とし穴」セクション- finally ブロックでオフにする:ライトを点灯させたままにすると、バッテリーを消耗し、他のカメラ利用を妨げます。
- Webの権限:モバイルブラウザでライトを使用するには、カメラの権限が必要です。
- 輝度(Intensity)のサポート:ハードウェアの最大値を超える値は制限されます。以下で確認してください:
isSwitchedOn().
API の概要
「API 概要」セクションisAvailable
「isAvailable」セクションデバイスでフラッシュライトが利用可能か確認します。
import { CapacitorFlash } from '@capgo/capacitor-flash';
const { value } = await CapacitorFlash.isAvailable();if (value) { console.log('Flashlight is available');}switchOn
「switchOn」セクションフラッシュライトをオンにします。
import { CapacitorFlash } from '@capgo/capacitor-flash';
// Turn on at full brightnessawait CapacitorFlash.switchOn({ intensity: 1.0 });
// Turn on at half brightnessawait CapacitorFlash.switchOn({ intensity: 0.5 });switchOff
「switchOff」セクションフラッシュライトをオフにします。
import { CapacitorFlash } from '@capgo/capacitor-flash';
await CapacitorFlash.switchOff();isSwitchedOn
「isSwitchedOn」セクション現在フラッシュライトがオンかオフかを確認します。
import { CapacitorFlash } from '@capgo/capacitor-flash';
const { value } = await CapacitorFlash.isSwitchedOn();console.log('Flashlight is on:', value);toggle
「toggle」セクションフラッシュライトのON/OFFを切り替えます。
import { CapacitorFlash } from '@capgo/capacitor-flash';
const { value } = await CapacitorFlash.toggle();console.log('Flashlight toggled, now on:', value);Source of Truth
「Source Of Truth」セクションこのページはプラグインの src/definitions.tsから生成されています。upstream で公開 API が変更されたら、再度 sync を実行してください。
Getting Startedの続きを進める
「Getting Started からの続き」セクション使用している場合 スタートガイド ダッシュボードと API の運用を計画するには、これを次と連携させます @capgo/capacitor-flash の使用方法 @capgo/capacitor-flash でネイティブ機能を使用する場合、 API の概要 「API の概要」の実装の詳細については、 はじめに 「はじめに」における実装の詳細については、 API キー および「API Keys」の実装の詳細については、 デバイス 実装の詳細については Devices を参照してください。