isAvailable()

Use this function to determine whether HealthService functionality is available.

Syntax 

1import { getHealthService } from 'lightning/mobileCapabilities';
2isAvailable(): Boolean

Parameters 

None.

Returns 

Returns true when used on a supported device and false otherwise.

Usage 

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