Building apps at a large company? Check out Ionic Enterprise

Stepcounter

Improve this doc

Cordova plugin for using device's stepcounter on Android (API > 19)

Use to

Repo: https://github.com/ihadeed/cordova-plugin-stepcounter

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-plugin-stepcounter
    $ npm install --save @ionic-native/stepcounter
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { Stepcounter } from '@ionic-native/stepcounter';

constructor(private stepcounter: Stepcounter) { }

...

let startingOffset = 0;
this.stepcounter.start(startingOffset).then(onSuccess => console.log('stepcounter-start success', onSuccess), onFailure => console.log('stepcounter-start error', onFailure));

this.stepcounter.getHistory().then(historyObj => console.log('stepcounter-history success', historyObj), onFailure => console.log('stepcounter-history error', onFailure));

Instance Members

start(startingOffset)

Start the step counter

Param Type Details
startingOffset number

will be added to the total steps counted in this session

Returns: Promise<any | number> Returns a Promise that resolves on success or rejects on failure

stop()

Stop the step counter

Returns: Promise<any | number> Returns a Promise that resolves on success with the amount of steps since the start command has been called, or rejects on failure

getTodayStepCount()

Get the amount of steps for today (or -1 if it no data given)

Returns: Promise<any | number> Returns a Promise that resolves on success with the amount of steps today, or rejects on failure

getStepCount()

Get the amount of steps since the start command has been called

Returns: Promise<any | number> Returns a Promise that resolves on success with the amount of steps since the start command has been called, or rejects on failure

deviceCanCountSteps()

Returns true/false if Android device is running >API level 19 && has the step counter API available

Returns: Promise<any | boolean> Returns a Promise that resolves on success, or rejects on failure

getHistory()

Get the step history (JavaScript object)

Returns: Promise<any> Returns a Promise that resolves on success, or rejects on failure

API

Native

General