react-native-stepcounter-ios-android
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

react-native-stepcounter-ios-android

React Native Pedometer for Android and IOS

Installation

npm install react-native-stepcounter-ios-android

Usage

import StepcounterIosAndroid from "react-native-stepcounter-ios-android";
 
// ...
 
React.useEffect(() => {
  StepcounterIosAndroid.isSupported()
    .then((result) => {
      if (result) {
        console.log('Sensor TYPE_STEP_COUNTER is supported on this device');
 
        const myModuleEvt = new NativeEventEmitter(
          NativeModules.StepcounterIosAndroid
        );
        myModuleEvt.addListener('StepCounter', (data) => {
          console.log('STEPS', data.steps);
          setSteps(data.steps);
        });
 
        StepcounterIosAndroid.startStepCounter();
      } else {
        console.log(
          'Sensor TYPE_STEP_COUNTER is not supported on this device'
        );
      }
    })
    .catch((err) => console.log(err));
 
  return () => StepcounterIosAndroid.stopStepCounter();
}, []);
 

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

Package Sidebar

Install

npm i react-native-stepcounter-ios-android

Weekly Downloads

9

Version

0.1.1

License

MIT

Unpacked Size

1.01 MB

Total Files

134

Last publish

Collaborators

  • rim23ma