requestHealthPermissions method

Future<bool> requestHealthPermissions(
  1. List<HealthDataType> types
)

Request permissions for the list of health types.

This method is called by the HealthProbe when it needs to access health data and is a more specific method than requestPermissions.

Implementation

Future<bool> requestHealthPermissions(List<HealthDataType> types) async {
  if (types.isEmpty) return true;

  info(
      '$runtimeType - Requesting permissions for health types: $types on ${Platform.operatingSystem}');

  try {
    return await service?.requestAuthorization(types) ?? false;
  } catch (error) {
    warning('$runtimeType - Error requesting permissions - $error');
  }
  return false;
}