MaikuB / flutter_local_notifications

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

Callback on scheduled notification shown (Android) #1699

Open noinskit opened 1 year ago

noinskit commented 1 year ago

Now that the plugin is open to running Flutter code in the background, what about optionally firing a callback when a scheduled notification is shown to the user? I think it's only doable on Android, so it would probably be an optional callback in AndroidInitializationSettings, with similar restrictions as onDidReceiveBackgroundNotificationResponse in initialize().

If the idea sounds reasonable, I might be able to prepare a merge request on my own.

MaikuB commented 1 year ago

Yep be open to a PR on this and if it's specific to Android then it should be specific to the Android implementaiton of the plugin. From my understanding, this is only possible on Android like you said as the callback on iOS/macOS that takes place before a notification is shown only triggers when the app is in the foreground (see https://developer.apple.com/documentation/usernotifications/unusernotificationcenterdelegate/1649518-usernotificationcenter)

pbayog00 commented 1 year ago

Are there any updates on this? I have not been able to find any PR related to this. Are we still not able to be aware of when a notification is shown to the user, regardless of it beeing tapped or not? Both for android and iOS

Gaurav-CareMonitor commented 11 months ago

@MaikuB Why is this not possible in iOS , since firebase also has a similar callback and it gets triggered in background in iOS

MaikuB commented 11 months ago

@Gaurav-CareMonitor Firebase deals with push notifications not local notifications so you're not doing a direct comparison. If you want to know then you should look at the notification APIs to understand how they work and the capabilities they expose

hobgoblina commented 8 months ago

Is any work being done on this already? Would be great to have for android. Dunno if I could make time to implement it myself anytime soon since I'm unfamiliar with this codebase.