@capawesome/capacitor-torch
v6.0.0
Published
Capacitor plugin for switching the flashlight on and off.
Downloads
90
Readme
@capawesome/capacitor-torch
Capacitor plugin for switching the flashlight on and off.
Installation
npm install @capawesome/capacitor-torch
npx cap sync
Android
Permissions
This API requires the following permissions be added to your AndroidManifest.xml
before the application
tag:
<!-- To get access to the flashlight. -->
<uses-permission android:name="android.permission.FLASHLIGHT"/>
Configuration
No configuration required for this plugin.
Demo
A working example can be found here: robingenz/capacitor-plugin-demo
Usage
import { Torch } from '@capawesome/capacitor-torch';
const enable = async () => {
await Torch.enable();
};
const disable = async () => {
await Torch.disable();
};
const isAvailable = async () => {
const result = await Torch.isAvailable();
return result.available;
};
const isEnabled = async () => {
const result = await Torch.isEnabled();
return result.enabled;
};
const toggle = async () => {
await Torch.toggle();
};
API
enable()
enable() => Promise<void>
Enable the torch.
Since: 6.0.0
disable()
disable() => Promise<void>
Disable the torch.
Since: 6.0.0
isAvailable()
isAvailable() => Promise<IsAvailableResult>
Check if the torch is available.
Returns: Promise<IsAvailableResult>
Since: 6.0.0
isEnabled()
isEnabled() => Promise<IsEnabledResult>
Check if the torch is enabled.
Returns: Promise<IsEnabledResult>
Since: 6.0.0
toggle()
toggle() => Promise<void>
Toggle the torch.
Since: 6.0.0
Interfaces
IsAvailableResult
| Prop | Type | Description | Since |
| --------------- | -------------------- | -------------------------------------- | ----- |
| available
| boolean | Whether the torch is available or not. | 6.0.0 |
IsEnabledResult
| Prop | Type | Description | Since |
| ------------- | -------------------- | ------------------------------------ | ----- |
| enabled
| boolean | Whether the torch is enabled or not. | 6.0.0 |
Changelog
See CHANGELOG.md.
License
See LICENSE.