flutter_local_notifications icon indicating copy to clipboard operation
flutter_local_notifications copied to clipboard

Feature request: Adding a way to update sticky notification text without stopping and restarting that notification

Open leaf-node opened this issue 1 year ago • 5 comments

stopForegroundService and startForegroundService can be used to update the text in a foreground service (sticky) notification in Android. However, that OS is slow to show newly created foreground services notifications (Maybe 10 - 20 seconds at times). It would be great if there were a way to change the title and body text without removing the current sticky notification.

I tried using second invocation of startForegroundService after the first invocation created the sticky notification, but that did not change the text.

leaf-node avatar Sep 19 '24 01:09 leaf-node

Could you help look into and submit a PR on this? Support for foreground service notifications was a contribution from the community that started with https://github.com/MaikuB/flutter_local_notifications/pulls?q=is%3Apr+is%3Aclosed+foreground

MaikuB avatar Oct 13 '24 01:10 MaikuB

I'm not sure when, but I'll take a look and see what I can do.

leaf-node avatar Oct 13 '24 01:10 leaf-node

@leaf-node, it seems from this SO answer that the standard way to update a notification created by a foreground service... is to just send a new notification with the same ID.

Can you try using the same ID you did in createForegroundService to call show() the standard way, and confirm that it changes your notification?

Levi-Lesches avatar Nov 26 '24 07:11 Levi-Lesches

Can you try using the same ID you did in createForegroundService to call show() the standard way, and confirm that it changes your notification?

I can confirm that works. Thanks for your help with research. : )

leaf-node avatar Nov 26 '24 20:11 leaf-node

Glad I can help! Let's leave this open for now and I will open a PR to improve the docs, since they explicitly suggest doing otherwise.

Levi-Lesches avatar Nov 26 '24 22:11 Levi-Lesches