mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-02-01 02:53:03 +08:00
feat(plugin): add Uptime plugin
This commit is contained in:
parent
e27009e7b5
commit
6be38328b0
46
src/@ionic-native/plugins/uptime/index.ts
Normal file
46
src/@ionic-native/plugins/uptime/index.ts
Normal file
@ -0,0 +1,46 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Plugin, Cordova, IonicNativePlugin} from '@ionic-native/core';
|
||||
|
||||
|
||||
/**
|
||||
* @name Uptime
|
||||
* @description
|
||||
* This plugin return the device uptime, without sleep time.
|
||||
*
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { Uptime } from '@ionic-native/uptime';
|
||||
*
|
||||
* constructor(private uptime: Uptime) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.uptime.getUptime()
|
||||
* .then((uptime: any) => console.log(uptime))
|
||||
* .catch((error: any) => console.log(error));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Uptime',
|
||||
plugin: 'cordova-plugin-uptime', // npm package name, example: cordova-plugin-camera
|
||||
pluginRef: 'Uptime', // the variable reference to call the plugin, example: navigator.geolocation
|
||||
repo: 'https://github.com/s1lviu/cordova-plugin-uptime', // the github repository URL for the plugin
|
||||
install: '', // OPTIONAL install command, in case the plugin requires variables
|
||||
installVariables: [], // OPTIONAL the plugin requires variables
|
||||
platforms: ['Android'] // Array of platforms supported, example: ['Android', 'iOS']
|
||||
})
|
||||
@Injectable()
|
||||
export class Uptime extends IonicNativePlugin {
|
||||
|
||||
/**
|
||||
* This function return system uptime
|
||||
* @return {Promise<any>} Returns a promise that resolves when something happens
|
||||
*/
|
||||
@Cordova()
|
||||
getUptime(): Promise<any> {
|
||||
return; // We add return; here to avoid any IDE / Compiler errors
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user