Develop Secure Code
HealthService Data Types
getHealthService()
isAvailable()
getWeight(options)
writeWeight(record)
isAvailable()Use this function to determine whether HealthService functionality is available.
1import { getHealthService } from 'lightning/mobileCapabilities';
2isAvailable(): BooleanNone.
Returns true when used on a supported device and false otherwise.
Use this function to disable or hide health data features on platforms where HealthService isn’t supported. For example:
1handleGetWeightClick() {
2 const myHealthService = getHealthService();
3 if (myHealthService.isAvailable()) {
4 // Perform health data operations
5 }
6 else {
7 // HealthService isn’t available, or consuming app hasn’t implemented it
8 // Not running on a device with a health store, etc.
9 // Handle with message, error, beep, and so on
10 }
11}See Also