Flashlight

This API allows you to switch the flashlight / torch of the device on and off.

Usage
Flashlight.available()
    .then(function(result) {
        if(result == 1){
            Flashlight.toggle().then(()=>{
                let status = Flashlight.isSwitchedOn() ? "ON" : "OFF";
                console.log("Flashlight is " +  status);
            });
        }else{
            console.log("Flashlight is unavailable");
        }
        
    })
    .catch(function(e) {
        console.error('Unable to get current SSID');
    });
window.Flashlight.available()
    .then(function (result) {
        if (result == 1) {
            window.Flashlight.toggle().then(() => {
                let status = window.Flashlight.isSwitchedOn() ? "ON" : "OFF";
                console.log("Flashlight is " + status);
            });
        } else {
            console.log("Flashlight is unavailable");
        }
    })
    .catch(function () {
        console.error("Unable to get current SSID");
    });
window.Flashlight.available()
    .then(function (result) {
        if (result == 1) {
            window.Flashlight.toggle().then(() => {
                let status = window.Flashlight.isSwitchedOn() ? "ON" : "OFF";
                console.log("Flashlight is " + status);
            });
        } else {
            console.log("Flashlight is unavailable");
        }
    })
    .catch(function () {
        console.error("Unable to get current SSID");
    });
(<any>window).Flashlight.available()
    .then(function (result) {
        if (result == 1) {
            (<any>window).Flashlight.toggle().then(() => {
                let status = (<any>window).Flashlight.isSwitchedOn() ? "ON" : "OFF";
                console.log("Flashlight is " + status);
            });
        } else {
            console.log("Flashlight is unavailable");
        }
    })
    .catch(() => {
        console.error("Unable to get current SSID");
    });
window.Flashlight.available()
    .then(function (result) {
        if (result == 1) {
            window.Flashlight.toggle().then(() => {
                let status = window.Flashlight.isSwitchedOn() ? "ON" : "OFF";
                console.log("Flashlight is " + status);
            });
        } else {
            console.log("Flashlight is unavailable");
        }
    })
    .catch(function () {
        console.error("Unable to get current SSID");
    });

Classes


Flashlight

available
available() Promise<int>

Check if Flashlight is available on the device.


RETURN
returns: Promise <int> Returns a Promise that resolves 0 - flashlight is unavailable, 1 - flashlight is available .
PERMISSIONS

This method requires CAMERA Permission set on Fawi Office - publish settings.

isSwitchedOn
isSwitchedOn() boolean

Check if Flashlight is switched on.


RETURN
returns: boolean
PERMISSIONS

This method requires CAMERA Permission set on Fawi Office - publish settings.

switchOn
switchOn() Promise<any>

Switch on the Flashlight.


RETURN
returns: Promise <any>
PERMISSIONS

This method requires CAMERA Permission set on Fawi Office - publish settings.

switchOff
switchOff() Promise<any>

Switch off the Flashlight.


RETURN
returns: Promise <any>
PERMISSIONS

This method requires CAMERA Permission set on Fawi Office - publish settings.

toggle
toggle() Promise<any>

Toggle the Flashlight.


RETURN
returns: Promise <any>
PERMISSIONS

This method requires CAMERA Permission set on Fawi Office - publish settings.