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

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



Solution 1:[1]

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

Solution 2:[2]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Aayush Bhattarai
Solution 2 Jesus Bernabeu Saez