Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(stepcounter): add stepcounter plugin #607

Merged
merged 2 commits into from
Oct 2, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ import { SpinnerDialog } from './plugins/spinnerdialog';
import { Splashscreen } from './plugins/splashscreen';
import { SQLite } from './plugins/sqlite';
import { StatusBar } from './plugins/statusbar';
import { Stepcounter } from './plugins/stepcounter';
import { StreamingMedia } from './plugins/streaming-media';
import { ThreeDeeTouch } from './plugins/3dtouch';
import { Toast } from './plugins/toast';
Expand Down Expand Up @@ -208,6 +209,7 @@ Sim,
Splashscreen,
SQLite,
StatusBar,
Stepcounter,
TouchID,
Transfer,
TextToSpeech,
Expand Down Expand Up @@ -310,6 +312,7 @@ window['IonicNative'] = {
Splashscreen,
SQLite,
StatusBar,
Stepcounter,
StreamingMedia,
ThreeDeeTouch,
Toast,
Expand Down
67 changes: 67 additions & 0 deletions src/plugins/stepcounter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { Plugin, Cordova } from './plugin';
/**
* @name Stepcounter
* @description
* Cordova plugin for using device's stepcounter on Android (API > 19)
*
* Use to
* - start and stop stepcounter service
* - read device's stepcounter data
*
* @usage
* ```
* import { Stepcounter } from 'ionic-native';
*
* let startingOffset = 0;
* Stepcounter.start(startingOffset).then(onSuccess => console.log('stepcounter-start success', onSuccess), onFailure => console.log('stepcounter-start error', onFailure));
*
* Stepcounter.getHistory().then(historyObj => console.log('stepcounter-history success', historyObj), onFailure => console.log('stepcounter-history error', onFailure));
*
* ```
*/
@Plugin({
plugin: 'https://github.com/texh/cordova-plugin-stepcounter',
pluginRef: 'stepcounter',
repo: 'https://github.com/texh/cordova-plugin-stepcounter',
platforms: ['Android']
})
export class Stepcounter {

/**
* Start the step counter
*
* @param startingOffset {number} will be added to the total steps counted in this session.
*/
@Cordova()
static start(startingOffset: number): Promise<number | any> { return; }

/**
* Stop the step counter
*/
@Cordova()
static stop(): Promise<number | any> { return; }

/**
* Get the amount of steps for today (or -1 if it no data given)
*/
@Cordova()
static getTodayStepCount(): Promise<number | any> { return; }

/**
* Get the amount of steps since the start command has been called
*/
@Cordova()
static getStepCount(): Promise<number | any> { return; }

/**
* Returns true/false if Android device is running >API level 19 && has the step counter API available
*/
@Cordova()
static deviceCanCountSteps(): Promise<boolean | any> { return; }

/**
* Get the step history (JavaScript object)
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing docs @returns ;)

@Cordova()
static getHistory(): Promise<any> { return; }
}