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

Adding HealthKit support #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Adding HealthKit support #15

wants to merge 1 commit into from

Conversation

haszz
Copy link

@haszz haszz commented Oct 27, 2024

Title: Add HealthKit Integration for Fitness and Activity Data Retrieval


Description:
This pull request introduces HealthKit support to the iOS PWA wrapper, providing capabilities for data authorization, retrieval, and JavaScript communication for fitness and activity data. The following major functionalities have been added:

Key Features and Changes:

  1. HealthKit Setup and Authorization:

    • setupHealthKit: Ensures HealthKit is available on the device.
    • requestAuthorization: Requests read access to specific HealthKit data types, including steps, distance, active energy, heart rate, and more.
    • checkAuthorizationStatus: Checks the authorization status for a specified HealthKit data type.
  2. Data Retrieval and Aggregation:

    • fetchHealthData: Aggregates data for steps, distance, and energy burned over the past three days and provides workout summaries.
    • fetchDetailedWorkouts: Retrieves details of recent workouts, including specific metrics such as active energy, elevation, speed, heart rate data, and step count.
  3. JavaScript Communication:

    • handleHealthKitPermission: Notifies the web view of authorization results (granted or denied).
    • handleHealthKitData: Passes retrieved HealthKit data to the web view in JSON format to enable further processing or display in the PWA.
  4. Helper Functions:

    • fetchActiveEnergy, fetchElevationData, fetchHeartRateData, fetchRouteData, fetchStepCount, and fetchFlightsClimbed: These helper methods retrieve detailed metrics for various workout activities.
    • fetchHeartRateTimeSeries: Gathers heart rate data over time for accurate visualization and analysis.
  5. Workout Activity Type Extension:

    • An extension on HKWorkoutActivityType has been added to map activity types to user-friendly names for display purposes.

Impact:

This enhancement enables PWAs to leverage HealthKit’s fitness data, making it possible to integrate rich health insights into the web-based app. Users can view their fitness metrics within the PWA interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants