HealthService User Experience
Use the HealthService API
HealthService Example
Compatibility and Requirements
Considerations and Limitations
Previous Versions
Keep these guidelines and limitations in mind when developing features that use the HealthService API.
Supported Data
In this release, HealthService supports reading and writing body-weight records only. Each weight value is expressed in kilograms (kg) or pounds (lbs).
The device’s health platform stores body mass without a unit. When you read records with getWeight(), HealthService converts the values to the unit that you specify in the preferredUnit option. If you don’t specify a unit, HealthService returns values in kilograms.
Device Limitations
HealthService doesn’t manage health data itself. Instead, it reads and writes data in the underlying platform’s health store, Apple HealthKit on iOS or Android Health Connect on Android. While the features provided by HealthService are the same across both platforms, they’re subject to some platform-specific quirks and minor differences.
HealthServiceFailure.code value of USER_DENIED_PERMISSION. If the user has denied permission and needs to change it to allow access, they can do so in their device’s settings.PROVIDER_NOT_INSTALLED or PROVIDER_UPDATE_REQUIRED code so that your component can display a message.If you’re having trouble getting HealthService to access health data, try these steps.
getWeight() and the structure of the record that you pass to writeWeight().Development Considerations
Virtual devices don’t always have health data when they’re created. To test reading weight history on a virtual device, first write some weight records with writeWeight(), or add records in the device’s native health app.
You can certainly develop the user experience for your component on a desktop or laptop development system. But be sure to test health data functionality on the physical devices on which you plan to deploy your Lightning app.
Apple and Google provide their own guidance for working with health data.
HealthService Considerations
Be aware of these considerations when using HealthService in your Lightning app.
WeightRecord object correctly. Provide a value greater than 0 and a valid unit.SERVICE_NOT_ENABLED code indicates that the capability is turned off for the app, while permission-related error codes indicate that the user has denied access.