From 6be38328b049b27d0bc0f0001f316699a1f42677 Mon Sep 17 00:00:00 2001 From: Silviu Bogdan Stroe Date: Wed, 4 Apr 2018 16:53:19 +0300 Subject: [PATCH] feat(plugin): add Uptime plugin --- src/@ionic-native/plugins/uptime/index.ts | 46 +++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/@ionic-native/plugins/uptime/index.ts diff --git a/src/@ionic-native/plugins/uptime/index.ts b/src/@ionic-native/plugins/uptime/index.ts new file mode 100644 index 000000000..462a725be --- /dev/null +++ b/src/@ionic-native/plugins/uptime/index.ts @@ -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} Returns a promise that resolves when something happens + */ + @Cordova() + getUptime(): Promise { + return; // We add return; here to avoid any IDE / Compiler errors + } + +} +