mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-03-16 00:11:10 +08:00
feat(stepcounter): add stepcounter plugin (#607)
* feat(stepcounter): add stepcounter plugin * docs(stepcounter): add missing returns
This commit is contained in:
parent
8f26f4b3ef
commit
a99b753d2d
@ -94,6 +94,7 @@ import { SpinnerDialog } from './plugins/spinnerdialog';
|
|||||||
import { Splashscreen } from './plugins/splashscreen';
|
import { Splashscreen } from './plugins/splashscreen';
|
||||||
import { SQLite } from './plugins/sqlite';
|
import { SQLite } from './plugins/sqlite';
|
||||||
import { StatusBar } from './plugins/statusbar';
|
import { StatusBar } from './plugins/statusbar';
|
||||||
|
import { Stepcounter } from './plugins/stepcounter';
|
||||||
import { StreamingMedia } from './plugins/streaming-media';
|
import { StreamingMedia } from './plugins/streaming-media';
|
||||||
import { ThreeDeeTouch } from './plugins/3dtouch';
|
import { ThreeDeeTouch } from './plugins/3dtouch';
|
||||||
import { Toast } from './plugins/toast';
|
import { Toast } from './plugins/toast';
|
||||||
@ -208,6 +209,7 @@ Sim,
|
|||||||
Splashscreen,
|
Splashscreen,
|
||||||
SQLite,
|
SQLite,
|
||||||
StatusBar,
|
StatusBar,
|
||||||
|
Stepcounter,
|
||||||
TouchID,
|
TouchID,
|
||||||
Transfer,
|
Transfer,
|
||||||
TextToSpeech,
|
TextToSpeech,
|
||||||
@ -310,6 +312,7 @@ window['IonicNative'] = {
|
|||||||
Splashscreen,
|
Splashscreen,
|
||||||
SQLite,
|
SQLite,
|
||||||
StatusBar,
|
StatusBar,
|
||||||
|
Stepcounter,
|
||||||
StreamingMedia,
|
StreamingMedia,
|
||||||
ThreeDeeTouch,
|
ThreeDeeTouch,
|
||||||
Toast,
|
Toast,
|
||||||
|
73
src/plugins/stepcounter.ts
Normal file
73
src/plugins/stepcounter.ts
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
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
|
||||||
|
* @return {Promise} Returns a Promise that resolves on success or rejects on failure
|
||||||
|
*/
|
||||||
|
@Cordova()
|
||||||
|
static start(startingOffset: number): Promise<number | any> { return; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop the step counter
|
||||||
|
* @return {Promise} Returns a Promise that resolves on success with the amount of steps since the start command has been called, or rejects on failure
|
||||||
|
*/
|
||||||
|
@Cordova()
|
||||||
|
static stop(): Promise<number | any> { return; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the amount of steps for today (or -1 if it no data given)
|
||||||
|
* @return {Promise} Returns a Promise that resolves on success with the amount of steps today, or rejects on failure
|
||||||
|
*/
|
||||||
|
@Cordova()
|
||||||
|
static getTodayStepCount(): Promise<number | any> { return; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the amount of steps since the start command has been called
|
||||||
|
* @return {Promise} Returns a Promise that resolves on success with the amount of steps since the start command has been called, or rejects on failure
|
||||||
|
*/
|
||||||
|
@Cordova()
|
||||||
|
static getStepCount(): Promise<number | any> { return; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true/false if Android device is running >API level 19 && has the step counter API available
|
||||||
|
* @return {Promise} Returns a Promise that resolves on success, or rejects on failure
|
||||||
|
*/
|
||||||
|
@Cordova()
|
||||||
|
static deviceCanCountSteps(): Promise<boolean | any> { return; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the step history (JavaScript object)
|
||||||
|
* @return {Promise} Returns a Promise that resolves on success, or rejects on failure
|
||||||
|
*/
|
||||||
|
@Cordova()
|
||||||
|
static getHistory(): Promise<any> { return; }
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user