matinzd / react-native-health-connect

React native library for health connect (Android only)
http://matinzd.github.io/react-native-health-connect
MIT License
233 stars 43 forks source link

Can't get past requestPermission #137

Closed BlocknBoom123 closed 2 months ago

BlocknBoom123 commented 3 months ago

My program keeps getting stuck on requestPermission as the promise never resolves. It never returns the grantedPermissions object and it remains empty. I get the dialogue box to allow access to health connect but when I click steps/distance and click allow, I get back to my main screen and no state is updated, as hitting allow doesn't finish that requestPermission method. It will never reach that console.log('hello) step or write to my state field, and as such androidPermissions remains empty. I'm not using expo.

console.log('1');
const grantedPermissions = await requestPermission([
  { accessType: 'read', recordType: 'Steps' },
  { accessType: 'read', recordType: 'Distance' },
]);
console.log('hello')
setAndroidPermissions(grantedPermissions);

image

matinzd commented 3 months ago

Did you follow the document to setup your Android project in the native code?

https://matinzd.github.io/react-native-health-connect/docs/get-started

BlocknBoom123 commented 3 months ago

Yes I did. I do get permissions but await requestPermission() will never finish running and return the granted permissions. I have to run requestPermissions twice to see the updated permissions using getGrantedPermissions.

Also, how do we link/grab the steps or distance for each exercise session? I can read the cycling, walking, or running sessions I've done but I can't get their respective distances. How do I get that?

Lastly, do you know how distance is actually recorded? Because I see loads of distance records that last around 2 ms each, instead of entire walking sessions around 30 minutes.

matinzd commented 3 months ago

Please open another issue for the second question. For the permission issue please send me a reproduction so I can find what's going on.

matinzd commented 3 months ago

Also try to always fill in the bug report template for other repositories as well. Removing the template and not providing any debug/version information will reduce the possibility of fixing the issue.

Thanks for your collaboration.

heritvithalani19 commented 2 months ago

@matinzd I faced the same issue .requestPermission as the promise never resolves. try { const androidPermission = await requestPermission([ { accessType: 'read', recordType: 'HeartRate' }, ]); console.log('Response:', androidPermission); // Debugging line } catch (error) { console.log(error) }

heritvithalani19 commented 2 months ago

@BlocknBoom123

Yes I did. I do get permissions but await requestPermission() will never finish running and return the granted permissions. I have to run requestPermissions twice to see the updated permissions using getGrantedPermissions.

Also, how do we link/grab the steps or distance for each exercise session? I can read the cycling, walking, or running sessions I've done but I can't get their respective distances. How do I get that?

Lastly, do you know how distance is actually recorded? Because I see loads of distance records that last around 2 ms each, instead of entire walking sessions around 30 minutes.

Has there been any progress on finding a solution to this issue?

matinzd commented 2 months ago

Duplicate of https://github.com/matinzd/react-native-health-connect/issues/147.

Closing.