I have a rather simple requirement for my flutter app but don’t know how to implement it.
Requirement
The user can select a date and time in future and a repeat interval (daily, weekly, monthly, weekdays). When the time has come a local notification is shown and from that time the notification is repeated based on the selected repeat interval. It should also be compatible with firebase cloud messaging (FCM).
Based on my researches flutter does not natively support notifications and there are only 2 packages from the community.
1. flutter_local_notifications
-
It does support
notificationsPlugin.periodicallyShow(RepeatInterval repeatInterval)
but there is no option to specify a start date => The periodic notification is scheduled from the time it is created, which is not what I want. -
There is also the method
notificationsPlugin.zonedSchedule
where you can pass aDateTimeComponents
to repeat it. But here the docs say:
Note that when a value is given, the [scheduledDate]
may not represent the first time the notification will be shown. An
example would be if the date and time is currently 2020-10-19 11:00
(i.e. 19th October 2020 11:00AM) and [scheduledDate] is 2020-10-21
10:00 and the value of the [matchDateTimeComponents] is
DateTimeComponents.time], then the next time a notification will
appear is 2020-10-20 10:00.
https://github.com/MaikuB/flutter_local_notifications/blob/master/flutter_local_notifications/lib/src/flutter_local_notifications_plugin.dart#L323
- Another option would be to schedule a non-repeating notification and re-schedule it to the next repeat date once the notification is shown, unfortunately the package does not provide listeners like
onNotificationDisplayed or onNotificationDismissed. Therefore the only option is to rely on the user that he opens the app after a notification is displayed to be able to re-schedule it.
2. awesome_notifications
This package is apparently not compatible with FCM, therefore they offer the paid plugin awesome_notifications_fcm. This is not an option because I want to use the native FCM packages.
So what is the way to go? Is there an option beside contributing to the existing library or implement my own logic from scratch?