Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: For SDK 34 : Showing Allow limit in pop up. #1390

Open
3 of 5 tasks
book-g opened this issue Sep 30, 2024 · 0 comments
Open
3 of 5 tasks

[Bug]: For SDK 34 : Showing Allow limit in pop up. #1390

book-g opened this issue Sep 30, 2024 · 0 comments

Comments

@book-g
Copy link

book-g commented Sep 30, 2024

Please check the following before submitting a new issue.

Please select affected platform(s)

  • Android
  • iOS
  • Windows

Steps to reproduce

It not supporting . When application open , App crashes,

Compile and Target SDK - 34 this issue occurs.

  1. Will pop up on the permission is throws the allow limit.
Future<bool> requiredPermissions() async {
  bool allowPermission = false;

  // Get Android SDK version
  bool isSdkBelow34 = false;
  try {
    AndroidDeviceInfo androidInfo = await DeviceInfoPlugin().androidInfo;
    int androidVersion = androidInfo.version.sdkInt;
    isSdkBelow34 = androidVersion < 34;

    print('Mobile SDK Version: $androidVersion');
  } catch (e) {
    print(e);
    Toast.toast("$e");
  }

  // Check permission statuses
  Map<Permission, bool> permissionsStatus = {
    Permission.scheduleExactAlarm: await Permission.scheduleExactAlarm.status.isGranted,
    Permission.reminders: await Permission.reminders.status.isGranted,
    Permission.location: await Permission.location.status.isGranted,
    Permission.camera: await Permission.camera.status.isGranted,
    Permission.accessMediaLocation: await Permission.accessMediaLocation.status.isGranted,
    Permission.storage: await Permission.storage.status.isGranted,
    Permission.photos: await Permission.photos.status.isGranted,
    Permission.videos: await Permission.videos.status.isGranted,
  };

  // Determine which permissions are required
  if (isSdkBelow34) {
    if (!permissionsStatus[Permission.location]!) {
      allowPermission = await showPermissionPopup();
      if (!allowPermission) return false;
    }
  } else {
    if (!permissionsStatus[Permission.scheduleExactAlarm]! ||
        !permissionsStatus[Permission.reminders]! ||
        !permissionsStatus[Permission.location]!) {
      allowPermission = await showPermissionPopup();
      if (!allowPermission) return false;
    }
  }

  // Request permissions if not granted
  for (var permission in permissionsStatus.keys) {
    if (!permissionsStatus[permission]! &&
        await permission.status != PermissionStatus.permanentlyDenied) {
      try {
        await permission.request();
      } catch (e) {
        Toast.toast("$e");
      }
    }
  }

  return true;
}

Expected results

  1. For Android Version 11 and below work fine
  2. Android 12,13,14 (API level 34) is the Android version for SDK 34. is not Working, since while upload in playstore. it say to upload SDK 34 for security reasons.

Actual results

A pop up for Photo and Video permission, Show Allow limit, need without Allow limit button.

Code sample

Code sample
  Future<bool> requiredPermissions() async {
    bool allowPermission = false;
    bool alarmStatus =
        await Permission.scheduleExactAlarm.status == PermissionStatus.granted;
    bool remindersStatus =
        await Permission.reminders.status == PermissionStatus.granted;
    bool locationStatus =
        await Permission.location.status == PermissionStatus.granted;
    bool cameraStatus =
        await Permission.camera.status == PermissionStatus.granted;
    bool mediaLocationStatus =
        await Permission.accessMediaLocation.status == PermissionStatus.granted;
    bool storageStatus =
        await Permission.storage.status == PermissionStatus.granted;
    bool photosStatus =
        await Permission.photos.status == PermissionStatus.granted;
    bool videoStatus =
        await Permission.videos.status == PermissionStatus.granted;

    // Mandatory permission
    bool isSdkBelow33 = false;
    bool isSdkBelow30 = false;
    try {
      AndroidDeviceInfo androidInfo = await DeviceInfoPlugin().androidInfo;
      int androidVersion = androidInfo.version.sdkInt;
      isSdkBelow33 = androidVersion < 33;
      isSdkBelow30 = androidVersion < 30;

      print('Mobile SDK Version: $androidVersion');
    } catch (e) {
      print(e);
      Toast.toast("$e");
    }

    if (isSdkBelow33) {
      if (!locationStatus) {
        allowPermission = await showPermissionPopup();
        if (!allowPermission) {
          SystemNavigator.pop();
        }
      }
    } else {
      if (!alarmStatus || !remindersStatus || !locationStatus) {
        allowPermission = await showPermissionPopup();
        if (!allowPermission) {
          SystemNavigator.pop();
        }
      }
    }

    if (!alarmStatus &&
        await Permission.scheduleExactAlarm.status !=
            PermissionStatus.permanentlyDenied) {
      try {
        await Permission.scheduleExactAlarm.request();
      } catch (e) {
        Toast.toast("$e");
      }
    }
    if (!remindersStatus &&
        await Permission.reminders.status !=
            PermissionStatus.permanentlyDenied) {
      try {
        //closeAppWhileDeny(
        await Permission.reminders.request();
        //);
      } catch (e) {
        Toast.toast("$e");
      }
    }
    if (!locationStatus &&
        await Permission.location.status !=
            PermissionStatus.permanentlyDenied) {
      try {
        closeAppWhileDeny(
            await Permission.location.request(), "Splash - Location");
      } catch (e) {
        Toast.toast("$e");
      }
    }

    if (!cameraStatus &&
        await Permission.camera.status != PermissionStatus.permanentlyDenied) {
      try {
        closeAppWhileDeny(await Permission.camera.request(), "Camera");
      } catch (e) {
        Toast.toast("$e");
      }
    }
    if (!mediaLocationStatus &&
        await Permission.accessMediaLocation.status !=
            PermissionStatus.permanentlyDenied) {
      try {
        //closeAppWhileDeny(
        await Permission.accessMediaLocation.request();
        //);
      } catch (e) {
        Toast.toast("$e");
      }
    }
    if (isSdkBelow30) {
      if (!storageStatus &&
          await Permission.storage.status !=
              PermissionStatus.permanentlyDenied) {
        try {
          closeAppWhileDeny(await Permission.storage.request(), "Storage");
        } catch (e) {
          Toast.toast("$e");
        }
      }
    } else {
      if (!storageStatus &&
          await Permission.storage.status !=
              PermissionStatus.permanentlyDenied) {
        try {
          // closeAppWhileDeny(
          //     await Permission.storage.request(),"Storage"
          // );
        } catch (e) {
          Toast.toast("$e");
        }
      }
      if (!photosStatus &&
          await Permission.storage.status !=
              PermissionStatus.permanentlyDenied) {
        try {
          await Permission.photos.request();
        } catch (e) {
          Toast.toast("$e");
        }
      }
      if (!videoStatus &&
          await Permission.storage.status !=
              PermissionStatus.permanentlyDenied) {
        try {
          await Permission.videos.request();
        } catch (e) {
          Toast.toast("$e");
        }
      }
    }

    // Mandatory permission
    if (isSdkBelow33) {
      if (!remindersStatus || !locationStatus) {
        await requiredPermissions();
      }
    } else {
      if (!alarmStatus || !remindersStatus || !locationStatus) {
        await requiredPermissions();
      }
    }

    return true;
  }

Screenshots or video

Screenshots or video demonstration

[Upload media here]

Version

^10.4.3

Flutter Doctor output

Doctor output
No exception on Exception, Showing wrong pop up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant