by Eddy Verbruggen for iOS, Android and WP8
This plugin allows you to switch the flashlight / torch of the device on and off.
Latest stable version from npm:
$ cordova plugin add cordova-plugin-flashlight
Bleeding edge version from Github:
$ cordova plugin add
Flashlight works with PhoneGap build too! Compatible with PhoneGap 3.0.0 and up.
Just add the following xml to your
config.xml to always use the latest version of this plugin:
Since version 3.2.0 of this plugin you can pass in an
which needs to be anywhere between 0.0 and 1.0. Only on iOS this will affect the
brightness of the torch.
As an alternative to
switchOff, you can use the
To know if the flashlight is on or off you can call
windowpluginsflashlight; // returns true/false
A hint for
Android developers: you'll want to make sure the torch is switched off when the app is exited via the backbutton.
Otherwise, the camera may be locked so it can't be used by other apps: