import { Injectable } from '@angular/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core'; /** * @name Flashlight * @description 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](https://github.com/EddyVerbruggen/Flashlight-PhoneGap-Plugin). * * @usage * ```typescript * import { Flashlight } from '@ionic-native/flashlight'; * * constructor(private flashlight: Flashlight) { } * * ... * * this.flashlight.switchOn(); * * ``` */ @Plugin({ pluginName: 'Flashlight', plugin: 'cordova-plugin-flashlight', pluginRef: 'window.plugins.flashlight', repo: 'https://github.com/EddyVerbruggen/Flashlight-PhoneGap-Plugin', platforms: ['Android', 'iOS', 'Windows Phone 8'] }) @Injectable() export class Flashlight extends IonicNativePlugin { /** * Checks if the flashlight is available * @returns {Promise} Returns a promise that resolves with a boolean stating if the flashlight is available. */ @Cordova() available(): Promise { return; } /** * Switches the flashlight on * @returns {Promise} */ @Cordova() switchOn(): Promise { return; } /** * Switches the flashlight off * @returns {Promise} */ @Cordova() switchOff(): Promise { return; } /** * Toggles the flashlight * @returns {Promise} */ @Cordova() toggle(): Promise { return; } /** * Checks if the flashlight is turned on. * @returns {boolean} */ @Cordova({ sync: true }) isSwitchedOn(): boolean { return; } }