Skip to content

Switch the Flashlight / Torch of your device.

Notifications You must be signed in to change notification settings

danielcowleypnp/capacitor-flash

 
 

Repository files navigation

capacitor-flash

Capgo - Instant updates for capacitor

Switch the Flashlight / Torch of your device.

Install

npm install @capgo/capacitor-flash
npx cap sync

iOS

Works out of the box

Android

  1. Declare permissions in your app's AndroidManifest.xml file
<!-- Permissions: Allows access to flashlight -->
<uses-permission android:name="android.permission.CAMERA" android:maxSdkVersion="23" />
<uses-permission android:name="android.permission.FLASHLIGHT" />

<!-- Actual Hardware Features Used-->
<uses-feature android:name="android.hardware.camera.flash" android:required="true" />

API

isAvailable()

isAvailable() => Promise<{ value: boolean; }>

Checks if flashlight is available

Returns: Promise<{ value: boolean; }>


switchOn(...)

switchOn(options: { intensity?: number; }) => Promise<void>

Turns the flashlight on

Param Type
options { intensity?: number; }

switchOff()

switchOff() => Promise<void>

Turns the flashlight off


isSwitchedOn()

isSwitchedOn() => Promise<{ value: boolean; }>

Checks if the flashlight is turned on or off

Returns: Promise<{ value: boolean; }>


toggle()

toggle() => Promise<{ value: boolean; }>

Toggle the flashlight

Returns: Promise<{ value: boolean; }>


About

Switch the Flashlight / Torch of your device.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 38.1%
  • Swift 25.8%
  • TypeScript 15.5%
  • Ruby 6.5%
  • Objective-C 6.4%
  • JavaScript 3.2%
  • Other 4.5%