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

Facing Consent required error while trying to read ExerciseSession #86

Open
abey-thomas opened this issue Apr 22, 2024 · 3 comments
Open
Labels
Type: feature request New feature or request

Comments

@abey-thomas
Copy link

Hi team, I am trying to read and write ExerciseSession record

Below permissions are added in androidManifest

    <uses-permission android:name="android.permission.health.READ_EXERCISE" />
    <uses-permission android:name="android.permission.health.WRITE_EXERCISE" />
    <uses-permission android:name="android.permission.health.READ_EXERCISE_ROUTE" />
    <uses-permission android:name="android.permission.health.WRITE_EXERCISE_ROUTE" />

Permissions are requested with below code

await requestPermission([
    { accessType: "read", recordType: "Steps" },
    { accessType: "read", recordType: "ActiveCaloriesBurned" },
    { accessType: "read", recordType: "ExerciseSession" },
  ]);

When I try to read data

await readRecords("ExerciseSession", {
    timeRangeFilter: {
      operator: "after",
      startTime: new Date(startDate.setHours(0, 0, 0, 0)).toISOString(),
    },
  });

I get error: [Error: Consent required]

I see the error comes from
ExerciseRouteResult.ConsentRequired

Could someone pls help to solve this?

@abey-thomas
Copy link
Author

I commented out below code in ReactExerciseSessionRecord.kt and am able to read route data as well.

  is ExerciseRouteResult.ConsentRequired -> {
          throw Exception("Consent required")
        }

Is there a better solution to this? @matinzd

@matinzd
Copy link
Owner

matinzd commented Apr 23, 2024

There is a better solution but unfortunately, I haven't had time to implement ExerciseRouteConsent in order for this to happen. Here is the open issue that you can follow:

#34

@ugurakin1
Copy link
Contributor

Maybe we should bubble consent required to RN/JS? Can make the exerciseRoute field an object with type and route? fields. Can include in #167

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: feature request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants