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

Insomnia

Improve this doc

Prevent the screen of the mobile device from falling asleep.

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

Installation

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

Supported platforms

Usage

import { Insomnia } from '@ionic-native/insomnia';

constructor(private insomnia: Insomnia) { }

...

this.insomnia.keepAwake()
  .then(
    () => console.log('success'),
    () => console.log('error')
  );

this.insomnia.allowSleepAgain()
  .then(
    () => console.log('success'),
    () => console.log('error')
  );

Instance Members

keepAwake()

Keeps awake the application

Returns: Promise<any>

allowSleepAgain()

Allows the application to sleep again

Returns: Promise<any>

API

Native

General