Prise en main
Copiez un prompt de configuration incluant les étapes d'installation et le guide markdown complet pour ce plugin.
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.
Installer
Section intitulée « Installation »Vous pouvez utiliser notre configuration assistée par IA pour installer le plugin. Ajoutez les skills Capgo à votre outil d'IA avec la commande suivante :
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsUtilisez ensuite le prompt suivant :
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-flash` plugin in my project.Si vous préférez une installation manuelle, installez le plugin en exécutant les commandes suivantes et suivez les instructions spécifiques à chaque plateforme ci-dessous :
bun add @capgo/capacitor-flashbunx cap syncImporter
Section intitulée « Import »import { CapacitorFlash } from '@capgo/capacitor-flash';Démarrage rapide
Section intitulée « Démarrage rapide »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 });Exemple : compagnon de scan QR
Section intitulée « Exemple : application compagnon de scan QR »await CapacitorFlash.switchOn({ intensity: 1 });const code = await scanFrame();await CapacitorFlash.switchOff();Erreurs courantes
Section intitulée « Erreurs courantes »- Éteindre dans le finally: laisser la lampe allumée vide la batterie et bloque les autres utilisateurs de la caméra.
- Permissions web : les navigateurs mobiles exigent l'autorisation caméra avant d'accéder à la torche.
- Prise en charge de l'intensité : les valeurs dépassant le maximum matériel sont bornées, vérifiez avec
isSwitchedOn().
Aperçu de API
Section intitulée « Aperçu API »isAvailable
Section intitulée « isAvailable »Vérifie si la torche est disponible sur l'appareil.
import { CapacitorFlash } from '@capgo/capacitor-flash';
const { value } = await CapacitorFlash.isAvailable();if (value) { console.log('Flashlight is available');}switchOn
Section intitulée « switchOn »Allume la torche.
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
Section intitulée « switchOff »Désactive la lampe torche.
import { CapacitorFlash } from '@capgo/capacitor-flash';
await CapacitorFlash.switchOff();isSwitchedOn
Section intitulée « isSwitchedOn »Vérifie si la torche est actuellement allumée ou éteinte.
import { CapacitorFlash } from '@capgo/capacitor-flash';
const { value } = await CapacitorFlash.isSwitchedOn();console.log('Flashlight is on:', value);Activez ou désactivez la lampe torche.
import { CapacitorFlash } from '@capgo/capacitor-flash';
const { value } = await CapacitorFlash.toggle();console.log('Flashlight toggled, now on:', value);Source de vérité
Section intitulée « Source de vérité »Cette page est générée à partir de src/definitions.ts. Relancez la synchronisation lorsque l’API public change en amont.
Continuer depuis Getting Started
Section intitulée « Continuer après Prise en main »Si vous utilisez Prise en main pour planifier les opérations du dashboard et de API, connectez-l’avec Utiliser @capgo/capacitor-flash pour la capacité native dans l'utilisation de @capgo/capacitor-flash, Aperçu de API pour les détails d'implémentation dans « Vue d'ensemble de API », Introduction pour les détails d'implémentation dans l'introduction, Clés API pour les détails d'implémentation dans « Clés API », et Appareils pour les détails d'implémentation dans Devices.