This project is a Tauri plugin which allows for flash control on iOS and Android devices with a consistent API.
| Platform | Supported |
|---|---|
| Linux | x |
| Windows | x |
| macOS | x |
| Android | ✓ |
| iOS | ✓ |
import { ping, toggle, check } from "@sosweetham/tauri-plugin-torch-api";
async function toggleTorch() {
const isTorchOn = await check();
if (isTorchOn) {
await toggle(false);
updateResponse("Torch is off");
} else {
await toggle(true);
updateResponse("Torch is on");
}
}
async function onTorch() {
toggle(true).then(updateResponse).catch(updateResponse);
}
async function offTorch() {
toggle(false).then(updateResponse).catch(updateResponse);
}
This permission set configures which torch features are by default exposed.
It allows access to all torch commands.
allow-toggleallow-check| Identifier | Description |
|---|---|
|
|
Enable the check command. |
|
|
Disable the check command. |
|
|
Enable the toggle command. |
|
|
Disable the toggle command. |
./permissions/autogenerated/commands, contrary to what the tauri documentation says.pnpm tauri [android|ios] dev to get the best experience. The IDEs are not aware of the Tauri build process and will not work as expected.android and ios folders in their respective IDEs (Android Studio and XCode) to get the best development experience.cargo build and pnpm build respectively.I have tested the plugin on a Pixel 8 Pro (Android 15) and iPhone 13 (iOS 18) and it works as expected. The implementations are really generic and should work on all devices. If you have a device that is not working, please open an issue.