HealthService User Experience
Use the HealthService API
HealthService Example
Compatibility and Requirements
Considerations and Limitations
Previous Versions
A Lightning web component can use a mobile device’s health store to read and write a user’s body-weight records. Your component can read weight history to display it in a Salesforce record, or write a new weight measurement back to the device’s health store.
Health data is stored locally on the mobile device, and HealthService doesn’t require a network connection. However, HealthService requires access to platform-specific APIs that are available only within compatible Salesforce mobile apps. On iOS, HealthService reads and writes data through Apple HealthKit. On Android, HealthService uses Android Health Connect.
HealthService does not and cannot function when running in a web browser, whether on a desktop or mobile device.
Important
Your component can deliver any user experience you want, but there’s a common flow for any component that reads or writes health data.
To develop a Lightning web component with health data features, use the HealthService API to read and write body-weight records on the device.
Here’s a minimal but complete example of a Lightning web component that uses HealthService to write a weight record to the device and read the weight history back again.
Compatibility and Requirements
HealthService is a JavaScript module that provides an API to Lightning web components to make mobile hardware and platform (operating system) features available in JavaScript. It requires access to device hardware and device platform APIs. This access is only available when HealthService runs within a compatible Salesforce mobile app. It does not and cannot function when running in a standard web browser, whether the browser runs on a desktop or mobile device.
Considerations and Limitations
Keep these guidelines and limitations in mind when developing features that use the HealthService API.
See Also