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

Android notification channels are created with Importance one level lower than specified. #2106

Closed
dupovalo opened this issue Oct 3, 2023 · 1 comment · Fixed by #2107
Closed

Comments

@dupovalo
Copy link

dupovalo commented Oct 3, 2023

Describe the bug

Creating an Android notification channel with specific Importance will result in a channel created with one level lower Importance.

PlatformException will be thrown if a channel is being created with Importance.unspecified (the first value of Importance enum).

Version info (from pubspec.yaml):
flutter_local_notifications: ^15.1.1

To Reproduce

  1. Obtain an instance of android platform plugin
// _localNotificationsPlugin initialization omitted for simplicity.
final androidPlugin = await _localNotificationsPlugin.resolvePlatformSpecificImplementation<AndroidFlutterLocalNotificationsPlugin>();
  1. Create a notification channel with specific Importance level.
androidPlugin.createNotificationChannel(
      AndroidNotificationChannel(
        'notification_channel_id',
        'notification_channel_name',
        importance: Importance.low,
      ),
    );
  1. List all registered channels.
final channels = await androidPlugin.getNotificationChannels();
for (final channel in channels) {
    print(' * [${channel.id}] [${channel.name}] [${channel.importance}]');
}
  1. Check the importance of registered channel in the logs.

Expected behavior
Channel should be created with Importance.low.

Actual behavior
Channel is created with Importance.min (one level lower as appears in Importance enum).

Additional note:
If a channel is created with Importance.unspecified (the lowest possible value as appears in Importance enum) then the following exception will occur at attempt to get a list of registered channels:

Unhandled Exception: PlatformException(error, Invalid importance level, null, java.lang.IllegalArgumentException: Invalid importance level
@MaikuB
Copy link
Owner

MaikuB commented Oct 4, 2023

Thanks for raising this. Channels are actually created properly. The bug is actually to do with the getNotificationChannels()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants