requestPermissions method

  1. @override
Future<bool> requestPermissions()
override

Request permission to access health data specified in the samplingConfiguration for this probe.

Note that this will show the Permission dialog to the user, asking for access to the health data. If the user denies access, this method will return false.

Note that on Android, if the user denies access to the health data types TWICE, then the permissions are permanently denied and the app cannot ask anymore. In this case, this method cannot be used to request permissions. Instead, the user must manually go to the settings of the phone and enable the permissions.

Implementation

@override
Future<bool> requestPermissions() async {
  bool permission = await hasPermissions();
  if (!permission) {
    permission = await deviceManager
        .requestHealthPermissions(samplingConfiguration.healthDataTypes);
  }
  return permission;
}