Switch the Flashlight / Torch of your device.
npm install @capgo/capacitor-flash
npx cap sync
Works out of the box
AndroidManifest.xml
file
<uses-permission android:name="android.permission.CAMERA" android:maxSdkVersion="23" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-feature android:name="android.hardware.camera.flash" android:required="true" />
isAvailable()
switchOn(...)
switchOff()
isSwitchedOn()
toggle()
isAvailable() => any
Checks if flashlight is available
Returns: any
switchOn(options: { intensity?: number; }) => any
Turns the flashlight on
Param | Type |
---|---|
options |
{ intensity?: number; } |
Returns: any
switchOff() => any
Turns the flashlight off
Returns: any
isSwitchedOn() => any
Checks if the flashlight is turned on or off
Returns: any
toggle() => any
Toggle the flashlight
Returns: any