Files
awesome-cordova-plugins/src/@ionic-native/plugins/insomnia/index.ts
T

57 lines
1.2 KiB
TypeScript
Raw Normal View History

import { Injectable } from '@angular/core';
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core';
2016-07-17 19:57:22 +02:00
2016-05-16 08:34:01 +02:00
/**
* @name Insomnia
* @description
* Prevent the screen of the mobile device from falling asleep.
*
* @usage
2016-07-20 17:17:09 +02:00
* ```typescript
* import { Insomnia } from '@ionic-native/insomnia';
2016-07-20 17:17:09 +02:00
*
* constructor(private insomnia: Insomnia) { }
2016-05-16 08:34:01 +02:00
*
* ...
*
* this.insomnia.keepAwake()
2016-05-16 08:34:01 +02:00
* .then(
* () => console.log('success'),
* () => console.log('error')
* );
*
* this.insomnia.allowSleepAgain()
2016-05-16 08:34:01 +02:00
* .then(
* () => console.log('success'),
* () => console.log('error')
* );
* ```
*
*/
@Plugin({
pluginName: 'Insomnia',
2016-05-16 08:34:01 +02:00
plugin: 'https://github.com/EddyVerbruggen/Insomnia-PhoneGap-Plugin.git',
pluginRef: 'plugins.insomnia',
repo: 'https://github.com/EddyVerbruggen/Insomnia-PhoneGap-Plugin',
2017-06-02 21:34:18 +02:00
platforms: ['Android', 'Browser', 'Firefox OS', 'iOS', 'Windows', 'Windows Phone 8']
2016-05-16 08:34:01 +02:00
})
@Injectable()
export class Insomnia extends IonicNativePlugin {
2016-05-16 08:34:01 +02:00
/**
* Keeps awake the application
* @returns {Promise<any>}
2016-05-16 08:34:01 +02:00
*/
@Cordova()
keepAwake(): Promise<any> { return; }
2016-05-16 08:34:01 +02:00
/**
* Allows the application to sleep again
* @returns {Promise<any>}
2016-05-16 08:34:01 +02:00
*/
@Cordova()
allowSleepAgain(): Promise<any> { return; }
2016-07-17 19:57:22 +02:00
2016-05-16 08:34:01 +02:00
}