flutter_notification_permissions icon indicating copy to clipboard operation
flutter_notification_permissions copied to clipboard

[Android] Using 'requestNotificationPermissions' doesn't wait for result

Open burekas7 opened this issue 4 years ago • 2 comments

Hi,

I'm using 'requestNotificationPermissions' in this way: var hasNotificationPermissions = true;

  static Future<bool> checkNotificationPermissions() async {
    var hasNotificationPermissions = true;
    var hasNotificationPermissionsStatus =
        await NotificationPermissions.getNotificationPermissionStatus();
    if (hasNotificationPermissionsStatus == PermissionStatus.denied ||
        hasNotificationPermissionsStatus == PermissionStatus.unknown) {
      hasNotificationPermissionsStatus =
          await NotificationPermissions.requestNotificationPermissions(
              iosSettings: const NotificationSettingsIos(
                  alert: true, sound: false, badge: false),
              openSettings: true);
      if (hasNotificationPermissionsStatus == PermissionStatus.denied ||
          hasNotificationPermissionsStatus == PermissionStatus.unknown) {
        hasNotificationPermissions = false;
      }
    }

    return Future.value(hasNotificationPermissions);
  }

In this case, requestNotificationPermissions open the app setting, but the code continue and ignore the await, it doesn't waiting to the pressing of the back button in the settings screen and set hasNotificationPermissionsStatus with PermissionStatus.denied.

How can I solve this behavior?

Thanks.

burekas7 avatar Apr 18 '22 17:04 burekas7

Same issue, please fix this bug

offline-first avatar Aug 27 '22 05:08 offline-first

Same issue

AliEasy avatar Aug 26 '23 09:08 AliEasy