Home > Enterprise >  App's notification button action in flutter
App's notification button action in flutter

Time:01-10

TLDR: Is it possible to reschedule notification when notification action button is clicked, without running the flutter app?

I have a flutter app that reminds of things via notifications using awesome_notifications plugin, and it has a 'remind later' button.

I have written the reschedule logic in app, but the click on notification button has to open the app in order to run the code. I have tried to open the app, reschedule, then close with exit(0), but it leaves the app in background - at least on Android, and it is preferable to not exit the app programatially anyways. Is it possible to reschedule notification without running flutter app?

CodePudding user response:

It is not possible to reschedule a notification without running the Flutter app. When the notification action button is clicked, the Flutter app must be launched in order to handle the action.

One option you could consider is to use a background task to reschedule the notification. This would allow you to reschedule the notification without opening the app to the foreground.

To implement a background task in Flutter, you can use the flutter_background_fetch or workmanager package. These packages allow you to schedule a function to run in the background at regular intervals. You can use this function to reschedule the notification as needed.

  • Related