Skip to content

Latest commit

 

History

History
58 lines (38 loc) · 1.7 KB

readme.md

File metadata and controls

58 lines (38 loc) · 1.7 KB

cordova-plugin-uptime

This plugin provides the system uptime in milliseconds since boot, allowing developers to track how long a device has been running. This can be particularly useful for monitoring, diagnostics, or adding uptime information within an application.

Installation

$ ionic cordova plugin add cordova-plugin-uptime
$ npm install --save @ionic-native/uptime

Supported Platforms

  • Android
  • iOS

Usage

Ionic Framework 2+ - TypeScript

import { Uptime } from '@ionic-native/uptime';  

constructor(private uptime: Uptime) { }  

// ...

this.uptime.getUptime(includeDeepSleep)
  .then((uptime) => console.log('Uptime (ms): ', uptime))
  .catch((error) => console.log('Error: ', error));

ES5 usage:

Uptime.getUptime(includeDeepSleep,
    function(uptime) { 
        console.log('Uptime (ms): ', uptime);
    },
    function(err) {  
        console.log('Error: ', err);
    }
);

The includeDeepSleep is a boolean parameter. If set to true, the returned uptime includes the total uptime (including device sleeping time). Otherwise, it will be the uptime considering clock stops when the system enters deep sleep (CPU off, display dark, device waiting for external input), but is not affected by clock scaling, idle, or other power-saving mechanisms.

Contributing

If you would like to contribute to this plugin, please feel free to submit a pull request or open an issue on our GitHub repository.

Author

This plugin is made with ❤️ by Silviu Stroe

License

This project is licensed under the MIT License - see the LICENSE.md file for details.