cordova-simple-timer

0.0.3 • Public • Published

cordova-simple-timer

Simple timer plugin which uses Android AlarmManager

Installation

$ cordova plugin add https://www.github.com/dukhanov/cordova-simple-timer

Android

cordova build android

Plugin API

It has been currently stripped to the minimum needed from a Javascript app.

The following functions are available:

  • SimpleTimer.start(listener, error, config). Start timer with 1 minute interval (by default)
    • listener: called on timer tick
    • error: called on function error
    • config: plugin config
    • config.interval: timer interval in milliseconds (minimum is 30000)
    • config.useWakelock: use PowerManager.WakeLock (default is false)
  • SimpleTimer.stop(success, error). Stop timer
    • success: called on function success
    • error: called on function error

Sample usage code

function onTimerTick() {
    console.log('timer tick');
}

function errorStart(message) {
    console.log('timer start failed: ' + message);
}

function onStopped() {
    console.log('timer is stopped');
}

var config = {
    interval: 60000, // 60 seconds
    useWakelock: false
}

// Start
SimpleTimer.start(onTimerTick, errorStart, config);

// Stop
SimpleTimer.stop(onStopped)

Package Sidebar

Install

npm i cordova-simple-timer

Weekly Downloads

49

Version

0.0.3

License

Apache-2.0

Unpacked Size

21.3 kB

Total Files

7

Last publish

Collaborators

  • juangongora