Skip to content

RPPermissions

Requests the OS permissions declared on the sections of a RPConsentDocument.

This is the only place in Research Package which talks to the platform about permissions. It is used by RPUIVisualConsentStep when the step has RPVisualConsentStep.askPermission set to true, but can also be called directly by an app which wants to ask for a permission outside a consent flow.

Methods

request

Future<RPPermissionStatus> request(
  1. RPPermissionType type, {
  2. List<HealthDataType> healthDataTypes = const [],
})

Asks the OS for type and returns the outcome.

If the participant has already granted the permission the OS does not show a dialog and RPPermissionStatus.granted is returned right away.

healthDataTypes is only used for RPPermissionType.health, which is not a single permission — see requestHealthData. Without it that type resolves to RPPermissionStatus.unsupported.

Never throws — a platform without an implementation for the permission resolves to RPPermissionStatus.unknown rather than interrupting the consent flow.

requestHealthData

Future<RPPermissionStatus> requestHealthData(
  1. List<HealthDataType> types
)

Requests read access to health types and returns the outcome.

Health data is not one permission: Apple HealthKit and Android Health Connect authorise each HealthDataType separately, so the caller has to say which ones the study reads. An empty list resolves to RPPermissionStatus.unsupported — there is nothing to ask for.

Nothing is requested when access to all of types has already been given, because requestAuthorization can block in that case.

On iOS the returned status is optimistic. HealthKit does not disclose whether read access was granted — for privacy, an app cannot tell the difference between "no permission" and "no data" — so RPPermissionStatus.granted here means the authorisation sheet was shown without error, not that the participant agreed. Android Health Connect reports the real outcome.