Control the device's torch
npm install @britishgas-engineering/bg-react-native-torchControl the device's torch
---
npm install bg-react-native-torch
setEnabledState(newState: boolean)
Pass true to turn the torch on, or false to turn the torch off.
getAvailableState(): boolean
Returns true if torch is available, false otherwise.
getEnabledState(): boolean
Returns true if the torch is turned on, false otherwise.
Note: On iOS, this will not accurately track if the torch has been enabled using the Control Centre. i.e. if the torch has only been enabled through the Control Centre, this will still return false.
onStateChange(callback: (torchState: TorchState) => void): EventSubscription
Callback function will be called whenever the availability or enabled state of the torch changes. The torchState argument passed to the callback function contains the new states of the torch. When finished you should unsubscribe by calling .remove() on the returned EventSubscription.
````
interface TorchState {
enabled: boolean;
available: boolean;
}
Made with create-react-native-library