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

Updating a notification channel seems not possible #1246

Closed
EP-u-NW opened this issue Jul 27, 2021 · 3 comments · Fixed by #1272
Closed

Updating a notification channel seems not possible #1246

EP-u-NW opened this issue Jul 27, 2021 · 3 comments · Fixed by #1272

Comments

@EP-u-NW
Copy link
Contributor

EP-u-NW commented Jul 27, 2021

Using AndroidFlutterLocalNotificationsPlugin.createNotificationChannel does not update the notification channel.

This suprised me since the behavior of the native Android methods flutter_local_notifications is calling is to simply update a channel if a channel with the same key already exists.

Digging deeper shows that AndroidNotificationChannelAction can be used to explicitly update an already existing channel. But unfortunately the AndroidNotificationChannel class, which is the parameter for the above mentioned createNotificationChannel, does not allow setting such an action, despite already serializing it correctly and passing it correctly to the java side, see this line:

I would opt for making this action a parameter in the AndroidNotificationChannel class and not forcing it to AndroidNotificationChannelAction.createIfNotExists while serializing, so a developer has the control over what happens.

My current workaround is to delete all channels and recreate them.

@MaikuB
Copy link
Owner

MaikuB commented Jul 28, 2021

What were you trying to change though. Not sure I've missed something from what you've explained but Android itself doesn't allow for changing the majority of the notification channel details once created beyond the name and description as explained in https://developer.android.com/training/notify-user/channels

@EP-u-NW
Copy link
Contributor Author

EP-u-NW commented Jul 28, 2021

Oh, sorry I didn't mention that.

My app is listening for the devices current locale settings (in the "standard flutter way" with a localizations delegate) and localizes the channels name and description, so I need to update them.

@MaikuB
Copy link
Owner

MaikuB commented Jul 29, 2021

This is likely an oversight from when there was a contribution that added supported for creating notification channels and refactored some existing logic. This could probably be fixed by not bothering with specifying the channel action and some tweaks to the logic on the Android side. However, I've already got a few PRs to review including one from you so not something I could look into soon. If you've got time to look into submitting a PR for this then would happily at this ahead of the foreground service one if needed

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