-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
feat: adds a new method for requesting exercise permissions #167
base: main
Are you sure you want to change the base?
Conversation
@@ -34,12 +34,21 @@ class HealthConnectModule internal constructor(context: ReactApplicationContext) | |||
@ReactMethod | |||
override fun requestPermission( | |||
permissions: ReadableArray, | |||
providerPackageName: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't used so replaced it.
recordType: 'ExerciseSession', | ||
}, | ||
], | ||
true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added true
here, hard to see the diff
@@ -97,16 +97,20 @@ export function openHealthConnectDataManagement( | |||
*/ | |||
export function requestPermission( | |||
permissions: Permission[], | |||
providerPackageName = DEFAULT_PROVIDER_PACKAGE_NAME | |||
includeRoute?: boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Omitting this in arg in JS seems to cause issues atm:
Exception in native call
com.facebook.react.bridge.NativeArgumentsParseException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference (constructing arguments for HealthConnect.requestPermission at argument index 1)
val exerciseRoute = HealthConnectPermissionDelegate.launchExerciseRouteAccessRequestDialog(recordId) | ||
if (exerciseRoute != null) { | ||
promise.resolve(ReactExerciseSessionRecord.parseExerciseRoute(exerciseRoute)) | ||
} | ||
else{ | ||
promise.rejectWithException(ExerciseRouteAccessDenied()) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting some flaky results with exercises, everything returns permissions denied as in exerciseRoute is null and as is there is no way to know for certain if that's because there is no data or something is wrong with my patch/permissions etc. Maybe we should fetch the exercise record here and switch on ExerciseRouteResult
to determine whether to request permission or reject with "NoDataException". Could go hand in hand with this.
Will look into this further this weekend |
Changes
requestPermission
to accept an optional flag that indicates requested permissions should includewrite-route
permission. Removed the unusedproviderPackageName
arg from the method as well.Issues
#34