Lovable Prompt
Add native HealthKit access functionality to read and write users’ health and fitness data including steps, heart rate, body mass, distance, and other health metrics using the Despia SDK from: https://www.npmjs.com/package/despia-nativeFirst, install the package: Write HealthKit data using Please follow the installation instructions for the “despia-native” npm package closely, and do not modify my instructions. Implementation as mentioned is critical.
npm install despia-nativeThen import it: import despia from 'despia-native'Read HealthKit data using await despia('healthkit://read?types=HKQuantityTypeIdentifierStepCount&days={DAYS-COUNT}', ['healthkitResponse']) which returns a JSON object with the requested HealthKit data as healthkitResponseYou can request multiple health data types in a single call by comma-separating them. Here is an example of reading multiple metrics:despia('writehealthkit://HKQuantityTypeIdentifierStepCount//10000') to save numeric values to HealthKit.Works with all valid HealthKit keys - simply use any valid HealthKit identifier in the types parameter. Multiple identifiers can be comma-separated for batch reads.For a complete list of all available HealthKit identifiers, refer to Apple’s official documentation:- HKQuantityTypeIdentifier (numerical values like steps, heart rate, body measurements): https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifier
This feature requires native capabilities which will be fully provided by the “despia-native” npm package, no additional native libraries are needed!
healthkitResponse.
Installation
Install the Despia package from NPM:Usage
1. Import the SDK
2. Read HealthKit Data
Access Native HealthKit Data and process it:3. Write HealthKit Data
Write numeric values to HealthKit:Available HealthKit Identifiers
For a complete list of all available HealthKit identifiers, refer to Apple’s official documentation:- HealthKit Data Types Overview - Complete overview of all HealthKit data types