This API allows you to switch the flashlight / torch of the device on and off.
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");
});
available() Promise<int>
Check if Flashlight is available on the device.