Building apps at a large company? Check out Ionic Enterprise

Flashlight

Improve this doc

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

Requires Cordova plugin: cordova-plugin-flashlight. For more info, please see the Flashlight plugin docs.

Repo: https://github.com/EddyVerbruggen/Flashlight-PhoneGap-Plugin

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-plugin-flashlight
    $ npm install --save @ionic-native/flashlight
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { Flashlight } from '@ionic-native/flashlight';

constructor(private flashlight: Flashlight) { }

...

this.flashlight.switchOn();

Instance Members

available()

Checks if the flashlight is available

Returns: Promise<boolean> Returns a promise that resolves with a boolean stating if the flashlight is available.

switchOn()

Switches the flashlight on

Returns: Promise<boolean>

switchOff()

Switches the flashlight off

Returns: Promise<boolean>

toggle()

Toggles the flashlight

Returns: Promise<any>

isSwitchedOn()

Checks if the flashlight is turned on.

Returns: boolean

API

Native

General