MaikuB / flutter_local_notifications

A Flutter plugin for displaying local notifications on Android, iOS, macOS and Linux
2.46k stars 1.4k forks source link

Append body to notification #737

Closed SupertigerDev closed 4 years ago

SupertigerDev commented 4 years ago

Is there anyway to append more data to the notification? anyway to get the notification body by id?

MaikuB commented 4 years ago

Is there anyway to append more data to the notification?

This sounds very vague/generic. Could you please be more specific on what it is you're after. The title is confusing as well as a body is displayed in the notification so don't understand what you mean by appending the body to the notification

anyway to get the notification body by id?

There is a method to return pending notifications (i.e. scheduled notifications that haven't been delivered yet). You can refer to the example app and API reference for the plugin for sample code and to test it out

SupertigerDev commented 4 years ago

I mean the notification is sent but i wanna edit that notification and add more text to it, does that example show that?

MaikuB commented 4 years ago

"Editing"/updating a notification is done by triggering another notification with the same id

SupertigerDev commented 4 years ago

I see that but to append another text to the same notification, i need to get the old text. im making a chat application (which i might give up on because i dont understand mobx + animatedlist) and i want to edit the notification thats already sent

MaikuB commented 4 years ago

You need to save the previous text if you're going to look to append and/or looking at using the message style (it's Android-specific) that is in the example app

SupertigerDev commented 4 years ago

Oh okay. I thought there would be an easier way because I need to use a database to store all the notifications. Thanks for closing the issue, really really appreciate it.

MaikuB commented 4 years ago

If you're doing a chat app then you're really displaying the messages not notifications. You'll likely need to display the history of the conversation so far as well. You can't rely on notifications to append or build up a history as those could be removed at any time