MaikuB / flutter_local_notifications

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

[Feature Request] Add callbacks for notification when displayed #2327

Closed rfowler5 closed 5 months ago

rfowler5 commented 5 months ago

Currently, the only callback that can be passed is one that is triggered when a user interacts with the notification, e.g., tapping. Could we also have a callback that is triggered when a notification is displayed? No user interaction: the notification is displayed and then the callback is triggered.

The awesome_notifications package has this feature, so it is possible to implement for both ios and android. It would be nice to have this callback while still keeping the lightweight package that flutter_local_notifications is.

It isn't fully clear to me how this should be implemented, but I think a callback handle can be passed to the native code. The user notification center can have listeners (ios), and there is something similar for android (NotificationListenerService) with plugins already existing for android, e.g., https://pub.dev/packages/flutter_notification_listener.

MaikuB commented 5 months ago

There's an existing issue for this already though the title mentions Android so closing this as a duplicate. If you're in need of this then please look at submitting a PR. This is something I work in on my spare time and don't actually use. As such it would be good to have the community contribute back especially when a lot of the heavy lifting has already done