OvalMoney / react-native-fitness

A React Native module to interact with Apple Healthkit and Google Fit.
MIT License
343 stars 68 forks source link

_reactNativeFitness.default.PermissionKind.Step is undefined #52

Closed anshgupta1234 closed 4 years ago

anshgupta1234 commented 4 years ago

Copying straight out of the example, I have this code here:

import Fitness from '@ovalmoney/react-native-fitness';

getHealthData = () => {
    const permissions = [
      { kind: Fitness.PermissionKind.Step, access: Fitness.PermissionAccess.Write },
    ];

    Fitness.isAuthorized(permissions)
      .then((authorized) => {
        console.warn(Fitness.getSteps({ startDate: new Date(2020, 4, 12) }))
      })
      .catch((error) => {
        // Do something
      });
  };

However, it's throwing me an error saying that PermissionKind.Step is undefined. Any idea to why this might be?

antoinedelp commented 4 years ago

Try using Fitness.PermissionKind.Steps instead.

singh-karan-7 commented 4 years ago

Yeah, I have got same issue. "Steps" didn't work either.

singh-karan-7 commented 4 years ago

I think the issue is Expo. I was trying this on Expo project, maybe the same is your or others' case too. One needs to eject for it to work properly. But, I suggest if you do eject, don't use this code, rather, try the native code. Find it from Stackoverflow and try the native modules and then send that data to your React Native project.

Francesco-Voto commented 4 years ago

Hi @brar07 ,

Yes you cannot use this library with Expo Projects