parent
26db2cfcf9
commit
d845519361
@ -98,6 +98,7 @@ import { OneSignal } from './plugins/onesignal';
|
||||
import { PhotoViewer } from './plugins/photo-viewer';
|
||||
import { ScreenOrientation } from './plugins/screen-orientation';
|
||||
import { PayPal } from './plugins/pay-pal';
|
||||
import { Pedometer } from './plugins/pedometer';
|
||||
import { PhotoLibrary } from './plugins/photo-library';
|
||||
import { PinDialog } from './plugins/pin-dialog';
|
||||
import { Pinterest } from './plugins/pinterest';
|
||||
@ -229,6 +230,7 @@ export * from './plugins/network';
|
||||
export * from './plugins/nfc';
|
||||
export * from './plugins/onesignal';
|
||||
export * from './plugins/pay-pal';
|
||||
export * from './plugins/pedometer';
|
||||
export * from './plugins/photo-library';
|
||||
export * from './plugins/photo-viewer';
|
||||
export * from './plugins/pin-dialog';
|
||||
@ -361,6 +363,7 @@ window['IonicNative'] = {
|
||||
NavigationBar,
|
||||
Network,
|
||||
PayPal,
|
||||
Pedometer,
|
||||
PhotoLibrary,
|
||||
NFC,
|
||||
Printer,
|
||||
|
103
src/plugins/pedometer.ts
Normal file
103
src/plugins/pedometer.ts
Normal file
@ -0,0 +1,103 @@
|
||||
import { Plugin, Cordova } from './plugin';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
/**
|
||||
* Interface of a pedometer data object which is returned by watching for new data or by recieving historical data
|
||||
*/
|
||||
|
||||
export interface IPedometerData {
|
||||
startDate?: number;
|
||||
endDate?: number;
|
||||
numberOfSteps: number;
|
||||
distance: number;
|
||||
floorsAscended: number;
|
||||
floorsDescended: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Pedometer
|
||||
* @description
|
||||
* Fetch pedestrian-related pedometer data,
|
||||
* such as step counts and other information about the distance travelled.
|
||||
*
|
||||
* @usage
|
||||
* ```
|
||||
* import { Pedometer } from 'ionic-native';
|
||||
*
|
||||
* Pedometer.isDistanceAvailable()
|
||||
* .then((available: boolean) => console.log(available))
|
||||
* .catch((error: any) => console.log(error));
|
||||
*
|
||||
* Pedometer.startPedometerUpdates()
|
||||
* .subscribe((data: IPedometerData) => {
|
||||
* console.log(data);
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Pedometer',
|
||||
plugin: 'cordova-plugin-pedometer',
|
||||
pluginRef: 'pedometer',
|
||||
repo: 'https://github.com/leecrossley/cordova-plugin-pedometer',
|
||||
platforms: ['Android', 'iOS']
|
||||
})
|
||||
export class Pedometer {
|
||||
|
||||
/**
|
||||
* Checks if step counting is available. Only works on iOS.
|
||||
* @return {Promise<boolean>} Returns a promise that resolves when feature is supported (true) or not supported (false)
|
||||
*/
|
||||
@Cordova()
|
||||
static isStepCountingAvailable(): Promise<boolean> { return; }
|
||||
|
||||
/**
|
||||
* Distance estimation indicates the ability to use step information to supply the approximate distance travelled by the user.
|
||||
* This capability is not supported on all devices, even with iOS 8.
|
||||
* Only works on iOS.
|
||||
* @return {Promise<boolean>} Returns a promise that resolves when feature is supported (true) or not supported (false)
|
||||
*/
|
||||
@Cordova()
|
||||
static isDistanceAvailable(): Promise<boolean> { return; }
|
||||
|
||||
/**
|
||||
* Floor counting indicates the ability to count the number of floors the user walks up or down using stairs.
|
||||
* This capability is not supported on all devices, even with iOS 8.
|
||||
* Only works on iOS.
|
||||
* @return {Promise<boolean>} Returns a promise that resolves when feature is supported (true) or not supported (false)
|
||||
*/
|
||||
@Cordova()
|
||||
static isFloorCountingAvailable(): Promise<boolean> { return; }
|
||||
|
||||
/**
|
||||
* Starts the delivery of recent pedestrian-related data to your Cordova app.
|
||||
*
|
||||
* When the app is suspended, the delivery of updates stops temporarily.
|
||||
* Upon returning to foreground or background execution, the pedometer object begins updates again.
|
||||
* @return {Observable<IPedometerData>} Returns a Observable that recieves repeatly data from pedometer in background.
|
||||
*/
|
||||
@Cordova({
|
||||
observable: true,
|
||||
clearFunction: 'stopPedometerUpdates'
|
||||
})
|
||||
static startPedometerUpdates(): Observable<IPedometerData> { return; }
|
||||
|
||||
/**
|
||||
* Stops the delivery of recent pedestrian data updates to your Cordova app.
|
||||
* @return {Promise<boolean>} Returns a promise that resolves when pedometer watching was stopped
|
||||
*/
|
||||
@Cordova()
|
||||
static stopPedometerUpdates(): Promise<any> { return; }
|
||||
|
||||
/**
|
||||
* Retrieves the data between the specified start and end dates.
|
||||
* The startDate and endDate options are required and can be constructed in any valid JavaScript way
|
||||
* (e.g. new Date(2015, 4, 1, 15, 20, 00) is also valid, as is milliseconds).
|
||||
* Only works on iOS.
|
||||
* @param {any} options start date and en date where you want to get pedometer data
|
||||
* @return {Promise<IPedometerData>} Returns a promise that resolves when pedometer data found
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse'
|
||||
})
|
||||
static queryData(options: { startDate: Date, endDate: Date }): Promise<IPedometerData> { return; }
|
||||
}
|
Loading…
Reference in New Issue
Block a user