HealthService User Experience
Use the HealthService API
HealthService Example
Compatibility and Requirements
Considerations and Limitations
Previous Versions
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.
HealthService is available in Lightning apps that are distributed using Mobile Publisher for Experience Cloud.
HealthService is fully functional when used in a Lightning app or Lightning site that’s run from a compatible Mobile Publisher for Experience Cloud mobile app on a compatible iOS or Android mobile device. On iOS, HealthService requires iOS 17 or later and reads and writes data through Apple HealthKit. On Android, HealthService reads and writes data through Android Health Connect, which the user must have installed. See Requirements for Mobile Publisher for Experience Cloud, or the requirements page for your target mobile app, for specific device and operating system requirements.
HealthService is not fully available when running on other devices, such as a desktop, or when running in a web browser, even on a mobile device. It requires the Mobile Publisher for Experience Cloud app. The HealthService API is accessible in Lightning Experience on all devices, so your code won’t fail due to missing functions. However, when your app runs in a browser—desktop or mobile—it can use only HealthService constants and utility functions. Any health data operation fails.
The device’s health platform requires the host app to declare its intent to read and write health data before HealthService can access it.
NSHealthShareUsageDescription and NSHealthUpdateUsageDescription strings in its Info.plist file.android.permission.health.READ_WEIGHT and android.permission.health.WRITE_WEIGHT permissions, and disclose its use of health data in its Google Play Console Health Data Safety form.