Search code examples
flutteroauth-2.0fitness

Flutter Heath package requestAuthorization() always returns false


I'm going to use the flutter health package to get step data. But I can't get permission from Gmail for my app by using this method. I have already added test users to the Google console in the GCP project.

Any solution?


Solution

  • you have to add ACTIVITY_RECOGNITION for getting STEP Count permission in AndroidManifest.xml.

    <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
    

    And then using permission_handler ask for permission.

        if (Platform.isAndroid) {
      final permissionStatus = Permission.activityRecognition.request();
      if (await permissionStatus.isDenied ||
          await permissionStatus.isPermanentlyDenied) {
        showToast(
            'activityRecognition permission required to fetch your steps count');
        return;
      }
    }