Flutter_local_notifications: Support for scheduling with repeating interval

Created on 25 Apr 2018  路  9Comments  路  Source: MaikuB/flutter_local_notifications

It would be nice to be able to schedule repeating notifications (something like UNTimeIntervalNotificationTrigger on iOS / AlarmManager.setInexactRepeating() on Android).

enhancement

All 9 comments

Yep I was thinking about that but wasn't sure if many people use that feature :)
Will look into that soon given the issues I'm having with getting callbacks for custom actions to work and seeing if there'll be additional documentation on how that could be achieved with Flutter

can you provide more details about the scenario you're looking at? there are two options as far as i can tell

  1. schedule a notification to be displayed at a specified date and then repeat it every so often
  2. schedule a notification to be displayed every so often

I'm guessing you're more interested in the second scenario as UNTimeIntervalNotificationTrigger doesn't seem to be appropriate for the first scenari?. The reason I ask is that the second scenario doesn't fit with the current method that's exposed for scheduling notifications so it'd most likely be a new method. From what I can gather, the second scenario can't be done on iOS versions 8.x and 9.x as well

Thanks for looking into this.

For now my use case is that following a specific event I schedule a notification 24 hours later, with a repeating 24 hour interval following that. So that even if the user does not act and dismiss the first notification, there will be another one the day after, and so on.

A variant of this would be to schedule it at a specific time, say 3pm everyday.

The native classes I mentioned in my initial comment are used in a project where only the first use case got implemented.

Your first scenario seems to allow both use cases described above.

I'm not sure I understand your second scenario. Do you mean it's only scheduling with an interval computed from the current date? In that case it could fit my first use case, but not the second one.

An example of the second displaying a notification every hour, this sounds like your first use case. The second use case you gave sounds like something that could be added as extension of the existing schedule method. Whereas the other one would most likely need to be a new method exposed by the plugin. Bear in mind that if I do get to add support for either scenario that my aim is to only support what can be done by all platforms, which includes the old iOS versions that use the UILocalNotification API. Not sure if I should be concerned that I have yet to see a Xamarin or React Native plugin that can schedule repeating notifications though... My gut feeling is that the first use case is something you may need to handle as part of your own application. Alternatively, if you're only interested in Android (unlikely given we are talking about Flutter), you could try to use the android_alarm_manager plugin along with this one

I've released a new version that I believe should handle the first scenario you described. Whilst doing this,I couldn't find a good abstraction for the second scenario so I don't think that's going be handled in this plugin. I suggest you grab a local copy of the plugin's code, reference it in your application and tweak it to your needs

I tried the new release, and it looks like the Hourly & Daily intervals are switched, e.g. setting up notifications with Hourly but receiving them Daily. From a quick look at the code, I guess it's because the enum order in lib/flutter_local_notifications.dart does not match the order in the platform specific FlutterLocalNotificationsPlugin.m and RepeatInterval.java

Ok thanks I'll take a look at it. Was this on iOS or Android?

Edit: doh nvm, saw it. thanks for picking up on that

Released a new version with the fix now

Going to close this off. If you run into another bug, then you can open another issue :)

Was this page helpful?
0 / 5 - 0 ratings