react-native-pedometer-huangxt
v1.0.3
Published
React Native Pedometer.
Downloads
1
Maintainers
Readme
react-native-pedometer-huangxt
React Native pedometer support for iOS version 8.0 and higher and Android. The module is CMPedometer wrapper. More info about CMPedometer can be found in https://developer.apple.com/library/ios/documentation/CoreMotion/Reference/CMPedometer_class/
Install
npm install --save npm i react-native-pedometer-huangxt
# Or
yarn add react-native-pedometer-huangxt
then make sure it is well linked, for this you can run
yarn react-native link react-native-pedometer-huangxt
# Or
npx react-native link
more information here
Basic usage
// Import the react-native-pedometer module
import Pedometer from 'react-native-pedometer-huangxt';
// determine pedometer availability
Pedometer.isStepCountingAvailable((error, isAvailable) => {
// do something
});
Pedometer.isDistanceAvailable((error, isAvailable) => {
// do something
});
Pedometer.isFloorCountingAvailable((error, isAvailable) => {
// do something
});
Pedometer.isCadenceAvailable((error, isAvailable) => {
// do something
});
// start tracking from current time
const now = new Date();
Pedometer.startPedometerUpdatesFromDate(now.getTime(), pedometerData => {
// do something with pedometer data
});
// query pedometer data from selected date to other selected date
const startDate = new Date();
startDate.setHours(0, 0, 0, 0);
const endDate = new Date();
Pedometer.queryPedometerDataBetweenDates(startDate.getTime(), endDate.getTime(), pedometerData => {
// do something with pedometer data
});
// stop pedometer updates
Pedometer.stopPedometerUpdates();