flutter_local_notifications
flutter_local_notifications copied to clipboard
[Feature] Add setBypassDnd option to Android Notificationchannel creation
Hello, I like flutter_local_notifications much, but there is one feature I need and is missing. The feature I need is the option to set "setBypassDnd" by creating a Android Notificaitonchannel.
If I create a notification channel in java, I can set the option and after allowing this feature in notificaiton settings of Android, Notifications of this channel are also loud if dnd is on.
example code:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager notificationManager = getSystemService(NotificationManager.class);
String CHANNEL_ID = "alarm";
CharSequence name = "alarm";
String description = "alarm";
int importance = NotificationManager.IMPORTANCE_HIGH;
NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID, name, importance);
notificationChannel.setDescription(description);
notificationChannel.setBypassDnd(true);
if (notificationManager != null) {
notificationManager.createNotificationChannel(notificationChannel);
}
}
Through adding this feature I don't need duplicate code anymode.
Thank you, for your good work :)
How about submitting a PR given you have some Android code there as well? :)
I have made that change directly in a fork of this plugin to check if it works: https://github.com/adrianlzt/flutter_local_notifications/commit/3b8b20c945fc73317a2f76d3b9d710f2dd0481bd
But it doesn't work. The notification makes no sound.
Could also be that mi phone is a Xiaomi using MIUI. It does not have the option to allow apps to skip DND.
If you don't have access to a stock Android device then I would suggest looking at using an emulator. Note that I do have a Pixel 4 XL so I can use that to test a PR should one be submitted
I need the app to run in my phone. I have finally disabled DND before running the notification.