This post is about cordova insomnia plugin. Which prevent the mobile screen from turn down and locking while user is not touching the screen.
This feature used in applications when we read a lengthy document or watching a video in application. To use this feature in the app we need to install following plugin through CLI :
$ cordova plugin add https://github.com/EddyVerbruggen/Insomnia-PhoneGap-Plugin.git
$ cordova prepare
This plugin supports Android, iOS, Windows and wp8 applications.
To keeping your app awake call the following method:
<button onclick="window.plugins.insomnia.keepAwake()">keep awake</button>
You can allow your device to falling asleep using below method:
<button onclick="window.plugins.insomnia.allowSleepAgain()">allow sleep again</button>
This method allows device to turn down.
Hope this will help you... :)