Popup of HealthKit Permission is not appearing in real device and simulator in Flutter

Viewed 191

I had used the health package in flutter for steps and running data in android the google fit and physical activity permission are set perfectly but in iOS, it is not asking for health kit permission all other permissions are working perfectly fine here is the code which I had written for permission request

  Future<void> requestActivityPermission() async {
    if (Platform.isAndroid) {
      final permissionStatus = await Permission.activityRecognition.request();
      if (permissionStatus.isDenied || permissionStatus.isPermanentlyDenied) {
        _activityPermanenetlyDeniedCase();
        return;
      } else {
        permissionStatus.isGranted;
        fetchTotalStepData();
      }
    } else {
      final permissionStatus = await Permission.activityRecognition.request();
      if (permissionStatus.isDenied || permissionStatus.isPermanentlyDenied) {
        _activityPermanenetlyDeniedCase();
        return;
      } else {
        permissionStatus.isGranted;
        fetchTotalStepData();
      }
    }
  }

The requestActivityPermission function is called in the initState Method.

The _activityPermanenetlyDeniedCase function directly opens up, in that function i had a dialog box showing open setting, but in the setting there is no healthkit permission.

I am expecting a popup permission for healthKit

2 Answers

You need to specify which permission you are using in Info.plist file under ios/ directory.

<key>NSHealthShareUsageDescription</key>
<string>We will sync your data with the Apple Health app to give you better insights</string>
<key>NSHealthUpdateUsageDescription</key>
<string>We will sync your data with the Apple Health app to give you better insights</string>

Refer here

Check that the healthkit is activated in both the debug and release tabs

Related