Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for scheduling with repeating interval #25

Closed
deckerst opened this issue Apr 25, 2018 · 9 comments
Closed

Support for scheduling with repeating interval #25

deckerst opened this issue Apr 25, 2018 · 9 comments
Labels
enhancement New feature or request

Comments

@deckerst
Copy link

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

@MaikuB MaikuB added the enhancement New feature or request label Apr 26, 2018
@MaikuB
Copy link
Owner

MaikuB commented Apr 26, 2018

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

@MaikuB
Copy link
Owner

MaikuB commented Apr 27, 2018

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

@deckerst
Copy link
Author

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.

@MaikuB
Copy link
Owner

MaikuB commented Apr 27, 2018

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

@MaikuB
Copy link
Owner

MaikuB commented Apr 28, 2018

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

@deckerst
Copy link
Author

deckerst commented May 2, 2018

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

@MaikuB
Copy link
Owner

MaikuB commented May 2, 2018 via email

@MaikuB
Copy link
Owner

MaikuB commented May 2, 2018

Released a new version with the fix now

@MaikuB
Copy link
Owner

MaikuB commented May 9, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants