Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getAuthStatus Method Always returning 1 if permission is denied or granted. #394

Open
TarunBhan opened this issue Oct 24, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@TarunBhan
Copy link

Bug Description
I have to report Multiple
I am using AppleHealth.getAuthStatus but it is giving me same response as 1. is there any workaround to solve this issue.
Second Issue
i am getting Multiple Warning Sending Healthkit:activity no listeners registered.

Expected behaviour
unnecessary registered should not be fired or there is a method to disable these events.
Values of getAuthStatus while toggling the permission

Screenshots
WhatsApp Image 2024-10-24 at 08 57 39

  • Device: [e.g. iPhone16]

Additional context
where should we write the code for listener to read it
and for multiple listener is this the only way to write the code without empty dependency as mentioned in the doc
useEffect(() => {
if (!updateDataFromAppleHealth.flag) {
const throttledDispatch = throttle((type) => {
dispatch(dataFetchFlag({ flag: true }));
}, 5000);

  const eventEmitter = new NativeEventEmitter(NativeModules.AppleHealthKit);
  const stepCountListener = eventEmitter.addListener(
    "healthKit:StepCount:new",
    async () => {
      throttledDispatch("stepCount");
    }
  );

  return () => {
    stepCountListener.remove();
  };
}

});

@TarunBhan TarunBhan added the bug Something isn't working label Oct 24, 2024
@TarunBhan TarunBhan changed the title getAuthStatus Method Always returning if permission is denied or granted. getAuthStatus Method Always returning 1 if permission is denied or granted. Oct 24, 2024
@nickcherry
Copy link

nickcherry commented Oct 29, 2024

I've also found the response from getAuthStatus completely unreliable. It's not clear to me whether the result of initHealthKit is expected to indicate anything with regard to permissions (I feel like it should), but it seems to always be 1, regardless of whether deny all access or not. As a workaround, I've tried to eagerly request healthkit data (e.g. activity summary) and use the presence of an error to determine whether permission has been denied, but that even seems to be unreliable, as I'll just get an empty array with no error (if no permissions were ever granted) or zero'd out values (if specific metrics were granted then revoked). The inability to determine the permission status makes it very challenging to use this library in a production app.

@kaleb-dev
Copy link

kaleb-dev commented Nov 8, 2024

Same issue here. An alternative package is https://github.com/kingstinct/react-native-healthkit and I have test and it works great returning correct data for permission

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants