flutter_local_notifications icon indicating copy to clipboard operation
flutter_local_notifications copied to clipboard

Custom intervals for periodicallyShow

Open Zil85 opened this issue 5 years ago • 34 comments

Are there any thoughts on adding custom intervals for showing repeating notifications?

Currently it supports the repeat intervals (EveryMinute, Hourly, Daily, Weekly).

But for my case I would be interested in having the users select the interval themselves.

Without going to much into the businesslogic. Basically the user sets a reminder and chooses a time interval e.g. every 5min, 20min, 1.5hours, etc. It would most likely always be in the range of 5min - 4hours.

Zil85 avatar Aug 23 '18 08:08 Zil85

Have been thinking about it. The reason why it's not there was that there are devs that are also targeting iOS 8 and 9 and custom intervals like that aren't supported. However, the fraction of devices on those versions are very small so that's why I'm considering this ATM. This will mean it will be a function (possibly an overload) that only works for Android and iOS 10+ so will need to be clearly documented

MaikuB avatar Aug 23 '18 09:08 MaikuB

+1 ...I would need this as well! Hoping to set intervals in terms of every week, every other week, every three weeks, every four weeks...

mccadi avatar Aug 24 '18 19:08 mccadi

I have seen your fork and I'm always open to look at a PR :)

MaikuB avatar Aug 24 '18 21:08 MaikuB

I did, I just tried changing the static values for minute, hour, week, etc but I am not quite sure if this will work or repeat properly until testing, but iOS notifications seem to work. Also having trouble with android getting notifications to show reliably atm...currently a work in progress

mccadi avatar Aug 27 '18 13:08 mccadi

Is it possible to combine every other week with specific weekday (e.g.: Monday and Friday)?

LSmint avatar Oct 09 '19 10:10 LSmint

Any updates?

cesarureno avatar May 05 '20 07:05 cesarureno

@cesarureno I'm actually looking to close this now as no one has looked into contributing a PR despite how long this issue has been around. I would say if you're after this feature that you look into implementing yourself and submit a PR if possible

MaikuB avatar May 05 '20 08:05 MaikuB

Oh, I see @MaikuB I will start to try make some awesome, thanks for your time and your package

cesarureno avatar May 05 '20 08:05 cesarureno

Maybe you can do this by combining this package with flutter_background_fetch.

  • Just use schedule() to schedule the first notification and store the required interval and starttime in sqlite or shared prefs.
  • Create a headless task with flutter_background_fetch that runs in the background every 15 minutes.
  • Make the task check if the notification has been sent.
  • If it has not been sent schedule a new one based on the starttime + interval of the last notification.

Unfortunately the interval has to be > 15min and checking every 15 min will cost some battery.

Bryanx avatar May 14 '20 14:05 Bryanx

I want to be able to schedule a notification for e.g. each 3rd Thursday 18:00 - this is currently not possible. I can set that target date once with schedule but I want it to happen periodically. There is no callback when the notification is actually shown, right? With that, I could schedule the next occurrence.

chriswiesner avatar Jun 16 '20 12:06 chriswiesner

I'm also looking into 15-30 mins notification interval! I hope this change gets in

tindalida avatar Jul 29 '20 10:07 tindalida

@MaikuB It's been over 2 years and IOS 8/9 are less relevant. Maybe this should be reconsidered?

britannio avatar Oct 06 '20 00:10 britannio

@britannio if you had followed the discussions above then you should see that I said for others to submit a PR for this. Sounds like you need this perhaps you could look into doing so

MaikuB avatar Oct 06 '20 00:10 MaikuB

Hey! Maybe it would be cool to just take a Duration Object instead of the DateTimeComponent.

Or maybe it is possible to use a notificationShownCallback to schedule the next one.

mnehrig avatar Oct 27 '20 21:10 mnehrig

I have read that this should be taken over by the community, but I still have a suggestion, It may be easier to implement when sticking to the current structure and just expand it a little.

  1. Add the possibility of a specification. I mean something like:
daily.at (12.30,000)
weekly.at (Monday, Friday)
  1. For a wider spectrum, maybe add monthly and yearly.

M123-dev avatar Dec 21 '20 13:12 M123-dev

I'm also interested in custom scheduled intervals, so that I have one unique ID for one notification and it is pushed e.g. every 3 hours. Specifying a start and end time would also be cool, so that you can program medication reminder apps, for example. I'm still pretty new to Flutter and don't know every source of information. If there are other ways to do this, I would appreciate any tips.

vanessabin avatar Dec 22 '20 16:12 vanessabin

Maybe you can do this by combining this package with flutter_background_fetch.

  • Just use schedule() to schedule the first notification and store the required interval and starttime in sqlite or shared prefs.
  • Create a headless task with flutter_background_fetch that runs in the background every 15 minutes.
  • Make the task check if the notification has been sent.
  • If it has not been sent schedule a new one based on the starttime + interval of the last notification.

Unfortunately the interval has to be > 15min and checking every 15 min will cost some battery.

Hello @MaikuB . Please how does one make the task check if the notification has been sent

a-k-o-r-e-d-e avatar Mar 19 '21 06:03 a-k-o-r-e-d-e

Hi, I also wanted to show a notification on a specific date every year but currently I don't think it is possible. Is there any workaround for such situations ? Can we use Timer in the background and when timer finishes we shall schedule an instant notification ? Will this work ?

Or even we could reschedule the notification once the notification is received but there is no callback for this event

virajdoshi11 avatar Apr 09 '21 04:04 virajdoshi11

Is it possible to schedule a repeatable daily or weekly notification which will start running at a specific date and time. I was not able to implement it after a lot hours of trying out. If I schedule it to execute on every Monday starting from a specific date and time, then the scheduled date is ignored and next time a notification will appears is the next Monday. Any ideas or suggestions are welcome.

krstevski02 avatar Apr 12 '21 10:04 krstevski02

Is it possible to schedule a repeatable daily or weekly notification which will start running at a specific date and time. I was not able to implement it after a lot hours of trying out. If I schedule it to execute on every Monday starting from a specific date and time, then the scheduled date is ignored and next time a notification will appears is the next Monday. Any ideas or suggestions are welcome.

Se https://github.com/MaikuB/flutter_local_notifications/issues/1118

mvolpato avatar Apr 16 '21 09:04 mvolpato

Hi, I also wanted to show a notification on a specific date every year but currently I don't think it is possible. Is there any workaround for such situations ? Can we use Timer in the background and when timer finishes we shall schedule an instant notification ? Will this work ?

Or even we could reschedule the notification once the notification is received but there is no callback for this event

Is something like _scheduleWeeklyMondayTenAMNotification in the example not enough?

mvolpato avatar Apr 16 '21 09:04 mvolpato

Hi, I also wanted to show a notification on a specific date every year but currently I don't think it is possible. Is there any workaround for such situations ? Can we use Timer in the background and when timer finishes we shall schedule an instant notification ? Will this work ? Or even we could reschedule the notification once the notification is received but there is no callback for this event

Is something like _scheduleWeeklyMondayTenAMNotification in the example not enough?

@mvolpato I don't want to schedule the notification weekly. I am creating a birthday reminder app so, I want to schedule the notification at a particular date and time every year.

virajdoshi11 avatar Apr 16 '21 13:04 virajdoshi11

Hi, I also wanted to show a notification on a specific date every year but currently I don't think it is possible. Is there any workaround for such situations ? Can we use Timer in the background and when timer finishes we shall schedule an instant notification ? Will this work ? Or even we could reschedule the notification once the notification is received but there is no callback for this event

Is something like _scheduleWeeklyMondayTenAMNotification in the example not enough?

@mvolpato I don't want to schedule the notification weekly. I am creating a birthday reminder app so, I want to schedule the notification at a particular date and time every year.

I see. That is because DateTimeComponents does not have the a monthAndDay option, right? Then it does not look like it is possible.

mvolpato avatar Apr 16 '21 14:04 mvolpato

Can we use Timer in the background and when timer finishes we shall schedule an instant notification ? Will this work ? Or even we could reschedule the notification once the notification is received but there is no callback for this event

I see. That is because DateTimeComponents does not have the a monthAndDay option, right? Then it does not look like it is possible.

@mvolpato because of that very reason i also mentioned 2 other solutions and asked that if they would somehow work

virajdoshi11 avatar Apr 16 '21 14:04 virajdoshi11

https://github.com/MaikuB/flutter_local_notifications/blob/b7fa709a61207e9cd86b8d5be911c3b49b655776/flutter_local_notifications/lib/src/platform_flutter_local_notifications.dart#L333 We can allow users to pass calledAt so that notification can be scheduled later with repeat. With this, we can achieve custom time for peridicallyShow What do you think? This can save a lot of time doing background fetch and other logic to schedule

manojeeva avatar Aug 10 '21 04:08 manojeeva

https://github.com/MaikuB/flutter_local_notifications/blob/b7fa709a61207e9cd86b8d5be911c3b49b655776/flutter_local_notifications/lib/src/platform_flutter_local_notifications.dart#L333

We can allow users to pass calledAt so that notification can be scheduled later with repeat. With this, we can achieve custom time for peridicallyShow What do you think? This can save a lot of time doing background fetch and other logic to schedule

Can this give notification at a particular date every year @manojeeva ?

virajdoshi11 avatar Aug 12 '21 04:08 virajdoshi11

This will help https://www.youtube.com/watch?v=aQTvI8L-mZs

myselfuser1 avatar Mar 17 '23 12:03 myselfuser1

Hello,apart from custom intervals is there some way to change the body everytime the periodicallyshow displays the notification every hour/minute/day. Like I am making a quote generator app which sends notifications every hour with a different quote, I have a function which return random quotes on callback, but for if I use periodically Display it just simple shows the first fetched quote from the callback function. Any way to do this?

morpheus-30 avatar Jun 09 '23 20:06 morpheus-30

Any updates?

rgillera avatar Aug 02 '23 16:08 rgillera

https://github.com/MaikuB/flutter_local_notifications/blob/b7fa709a61207e9cd86b8d5be911c3b49b655776/flutter_local_notifications/lib/src/platform_flutter_local_notifications.dart#L333

We can allow users to pass calledAt so that notification can be scheduled later with repeat. With this, we can achieve custom time for peridicallyShow What do you think? This can save a lot of time doing background fetch and other logic to schedule

+1 I too need to be able to set the time when the notification should occur periodically. I just don't get, why there isn't a parameter for that, because the API apparently allows it...?

TruFelix avatar Oct 10 '23 11:10 TruFelix