Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

Brightness

Improve this doc

The Brightness plugin let you control the display brightness of your device.

Requires Cordova plugin: cordova-plugin-brightness. For more info, please see the Brightness plugin docs.

Repo: https://github.com/mgcrea/cordova-plugin-brightness

Installation

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

Supported platforms

Usage

import { Brightness } from '@ionic-native/brightness';

constructor(private brightness: Brightness) { }

...

let brightnessValue = 0.8;
this.brightness.setBrightness(brightnessValue);

Instance Members

setBrightness(value)

Sets the brightness of the display.

Param Type Details
value number

Floating number between 0 and 1 in which case 1 means 100% brightness and 0 means 0% brightness.

Returns: Promise<any> Returns a Promise that resolves if setting brightness was successful.

getBrightness()

Reads the current brightness of the device display.

Returns: Promise<any> Returns a Promise that resolves with the brightness value of the device display (floating number between 0 and 1).

setKeepScreenOn(value)

Keeps the screen on. Prevents the device from setting the screen to sleep.

Param Type Details
value boolean

API

Native

General