Can't get past requestPermission
Closed this issue · 7 comments
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);
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
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.
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.
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.
@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)
}
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?