HealthServiceManager
The DeviceManager for the HealthService.
Owns the Health plugin instance, keeps the set of health data types to access, and checks and requests permissions for them.
Key points:
- Types come from each HealthProbe (on initialize) and from the default sampling configuration of the HealthService (on configure).
- Connecting always succeeds once permissions are granted.
- On iOS, hasPermissions is true as soon as types are registered, because Apple Health does not disclose whether read access is granted.
- On Android below SDK level 34, it logs a warning that Health Connect must be installed as a separate app.
- Inheritance
-
- Object
- DeviceManager<
HealthService, ServiceRegistration> - ServiceManager<
HealthService, ServiceRegistration> - HealthServiceManager
Constructors
HealthServiceManager
- HealthService? configuration
Properties
canConnect
Determines whether a connection can be made at this point in time to the device.
displayName
service
The Health plugin, or null if this manager is not configured yet.
types
The health data types this service accesses.
Methods
addTypes
- List<
HealthDataType> types
Add a set of health types this service should access.
Types not supported on the current platform are ignored and logged as a warning.
createRegistration
Create a device registration which can be used to configure this device for deployment.
This method is used when a device is connected and a registration for this device is needed in the deployment and hence in the deployment service. The registration is typically created from the device information of the real device, e.g., the ID, name, and BLE address of the smartphone or a connected Bluetooth device.
gatherTypesFrom
- HealthService? service
Adds the health data types from the default sampling configuration of service for the HealthSamplingPackage.HEALTH measure, so that the right permissions can be requested.
Called when this manager is configured.
hasHealthPermissions
- List<
HealthDataType> types
Checks if the service has permissions to access 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 hasPermissions. Returns true if types is empty, and false if the check fails.
Note that this method always returns false on iOS, as there is no way to know if permissions are granted.
onConfigure
Callback on configure.
When called, the configuration and the registration is available.
Is to be overridden in sub-classes. Note, however, that it must not be doing a lot of work on startup.
onConnect
Callback on connect. Returns the DeviceStatus of the device.
Can be overridden for device-specific connection handling.
onDisconnect
Callback on disconnect.
This method is called after all sampling on this device has been stopped, and the device manager is trying to disconnect from the real device.
Is to be overridden in sub-classes and implement device-specific disconnection.
onHasPermissions
Callback on hasPermissions.
Can be overridden in sub-classes for device-specific permission handling.
onRequestPermissions
Callback on requestPermissions.
Can be overridden for device-specific permission handling.
requestHealthPermissions
- List<
HealthDataType> types
Requests 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. It shows the OS permission dialog. Returns true if types is empty, and false if the request fails.