Documentation Index
Fetch the complete documentation index at: https://mintlify.com/kingstinct/react-native-healthkit/llms.txt
Use this file to discover all available pages before exploring further.
saveQuantitySample
Save a new quantity sample to HealthKit.The quantity type identifier to save. Must be a writeable type (read-only types like
'HKQuantityTypeIdentifierAppleExerciseTime' cannot be written to)The unit of measurement for the quantity value (e.g.,
'count', 'kg', 'mi', 'IU')The numeric value of the quantity
The start date and time for the sample
The end date and time for the sample. For instantaneous measurements (like weight), this should typically be the same as the start date
Optional metadata to attach to the sample. Can include both built-in HealthKit metadata keys and custom app-specific data
Returns
The saved quantity sample, or undefined if the save failed
Examples
Save step count
Save weight measurement
Save insulin delivery with metadata
Save blood glucose with meal context
Some quantity types are read-only (like
HKQuantityTypeIdentifierAppleExerciseTime) and cannot be saved by third-party apps. These are defined as QuantityTypeIdentifierReadOnly in the type system.Metadata Keys
HealthKit metadata keys follow a specific naming pattern. In the Apple documentation, they appear with theHKMetadataKey prefix (e.g., HKMetadataKeyExternalUUID), but when serialized, they use the HK prefix (e.g., HKExternalUUID).
Common metadata keys include:
HKExternalUUID- Unique identifier from external systemHKWasUserEntered- Boolean indicating manual entryHKInsulinDeliveryReason- Reason for insulin delivery (basal/bolus)HKBloodGlucoseMealTime- Timing relative to mealsHKHeartRateMotionContext- Motion context for heart rate
Unit Compatibility
Use theisQuantityCompatibleWithUnit() helper function to check if a unit is compatible with a quantity type before saving: