flutter_notification_permissions icon indicating copy to clipboard operation
flutter_notification_permissions copied to clipboard

requestNotificationPermissions returns "unknown" even when it's actually granted

Open JmeHsieh opened this issue 5 years ago • 10 comments

If the permission status is currently unknown, requestNotificationPermissions will return granted if I accept the dialog, which is correct.

But when the status is already granted, requestNotificationPermissions always returns unknown, yet getNotificationPermissionStatus returns granted correctly.

Tested on iOS 12.1, 13.1, 13.2.

JmeHsieh avatar Oct 24 '19 09:10 JmeHsieh

Hello there!

Sorry for taking so long to reply.

Was this tested only on a simulator or also in physical devices?

Vanethos avatar Jan 06 '20 16:01 Vanethos

I was testing on physical iPhoneX

JmeHsieh avatar Jan 22 '20 05:01 JmeHsieh

Does the same happen with v0.4.4?

Vanethos avatar Feb 02 '20 14:02 Vanethos

@Vanethos I have this issue on a Oneplus 5 running Android 9 (didn't test any other version) with this code.

  onPressed: () async {
    PermissionStatus status = await NotificationPermissions.requestNotificationPermissions();
    print('Status: $status');
    final bool granted = status == PermissionStatus.granted;
    print('Granted: $granted');
    return Navigator.maybePop(context, granted);
  },

And this is the output:

I/flutter (15444): Status: PermissionStatus.unknown
I/flutter (15444): Granted: false

In the docs, it says Android will never have an unknown status, but I'm getting it. In app settings, notifications are enabled (fresh install of the app, so it should be enabled by default anyway). Also, if I manually disable them, it also prints unknown as status.

I'm using v0.4.4 and Flutter 1.15.4-pre.117 while debugging.

Zazo032 avatar Feb 20 '20 12:02 Zazo032

@Vanethos I'm having the same behavior with version 0.4.4 on an iPhone device with iOS 13.3.1

When the status is already granted, requestNotificationPermissions always returns unknown, yet getNotificationPermissionStatus returns granted correctly.

thearaks avatar Apr 30 '20 08:04 thearaks

@Vanethos this issue probably needs to be reopened. And probably is a high priority one... If you need help to make a fix let me know!

thearaks avatar Jun 02 '20 10:06 thearaks

@thearaks if you know or can work out a fix for this, you can submit a PR for it with the fix, so it can be fixed and published faster

Zazo032 avatar Jun 02 '20 11:06 Zazo032

@Zazo032 I'm not an expert iOS developer and, beside that, I prefer to get in touch with the maintainer before submitting a PR. The last thing I want is to spend time preparing a fix that will never be merged since I'm already pretty busy at the moment :)

thearaks avatar Jun 02 '20 19:06 thearaks

@thearaks in the following days I’ll be checking this issue, thanks for the heads up!

Vanethos avatar Jun 06 '20 11:06 Vanethos

@Vanethos hi! Any update on this issue? 😄

thearaks avatar Feb 03 '21 14:02 thearaks