ios-pwa-wrap
ios-pwa-wrap copied to clipboard
Adding HealthKit support
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:
-
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.
-
-
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.
-
-
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.
-
-
Helper Functions:
-
fetchActiveEnergy
,fetchElevationData
,fetchHeartRateData
,fetchRouteData
,fetchStepCount
, andfetchFlightsClimbed
: These helper methods retrieve detailed metrics for various workout activities. -
fetchHeartRateTimeSeries
: Gathers heart rate data over time for accurate visualization and analysis.
-
-
Workout Activity Type Extension:
- An extension on
HKWorkoutActivityType
has been added to map activity types to user-friendly names for display purposes.
- An extension on
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.