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

Custom intervals for periodicallyShow #92

Open
Zil85 opened this issue Aug 23, 2018 · 34 comments · May be fixed by #2197
Open

Custom intervals for periodicallyShow #92

Zil85 opened this issue Aug 23, 2018 · 34 comments · May be fixed by #2197
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@Zil85
Copy link

Zil85 commented Aug 23, 2018

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.

@MaikuB
Copy link
Owner

MaikuB commented Aug 23, 2018

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

@mccadi
Copy link

mccadi commented Aug 24, 2018

+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...

@MaikuB
Copy link
Owner

MaikuB commented Aug 24, 2018

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

@mccadi
Copy link

mccadi commented Aug 27, 2018

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

@LSmint
Copy link

LSmint commented Oct 9, 2019

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

@cesarureno
Copy link

Any updates?

@MaikuB
Copy link
Owner

MaikuB commented May 5, 2020

@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

@cesarureno
Copy link

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

@Bryanx
Copy link

Bryanx commented May 14, 2020

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.

@chriswiesner
Copy link

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.

@tindalida
Copy link

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

@britannio
Copy link

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

@MaikuB
Copy link
Owner

MaikuB commented Oct 6, 2020

@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 MaikuB added enhancement New feature or request help wanted Extra attention is needed labels Oct 6, 2020
@mnehrig
Copy link

mnehrig commented Oct 27, 2020

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.

@M123-dev
Copy link

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.

@vanessabin
Copy link

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.

@a-k-o-r-e-d-e
Copy link

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

@virajdoshi11
Copy link

virajdoshi11 commented Apr 9, 2021

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

@krstevski02
Copy link

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.

@mvolpato
Copy link

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 #1118

@mvolpato
Copy link

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?

@virajdoshi11
Copy link

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.

@mvolpato
Copy link

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.

@virajdoshi11
Copy link

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

@manojeeva
Copy link

manojeeva commented Aug 10, 2021


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

@virajdoshi11
Copy link

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 ?

@myselfuser1
Copy link

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

@morpheus-30
Copy link

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?

@rgillera
Copy link

rgillera commented Aug 2, 2023

Any updates?

@TruFelix
Copy link

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...?

@henriklagergren
Copy link

I had the same problem so have forked the repo and created a solution where you can send in repeatStartTime (which is an int representing timeSinceEpoch) into the periodicallyShow 😄

You can find it here: https://github.com/henriklagergren/flutter_local_notifications

Import it like this in your pubspec.yaml file:

flutter_local_notifications:
    git:
      url: https://github.com/henriklagergren/flutter_local_notifications.git
      path: flutter_local_notifications

@followthemoney1
Copy link

@henriklagergren time since, which one, milliseconds since approach?

@MaikuB
Copy link
Owner

MaikuB commented Mar 23, 2024

Note there is a PR at #2197. I've requested some changes but they're minor. If the community can help test out and confirm that it's all good then if the PR author doesn't get around to it then I could try to clean up the PR myself when I can

@anilslabs
Copy link

anilslabs commented Mar 27, 2024

@henriklagergren

I had the same problem so have forked the repo and created a solution where you can send in repeatStartTime (which is an int representing timeSinceEpoch) into the periodicallyShow 😄

You can find it here: https://github.com/henriklagergren/flutter_local_notifications

Import it like this in your pubspec.yaml file:

flutter_local_notifications:
    git:
      url: https://github.com/henriklagergren/flutter_local_notifications.git
      path: flutter_local_notifications

I tried using this fork, and it worked fine on Android only. On iOS, it seems to be ignoring the repeatStartTime or the calledAt. Also, I can't see any specific native implementation on the iOS side that is checking for calledAt or repeatStartTime in the periodicallyShow function. 

I am new to the native iOS development, so I cannot exactly say what the issue is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet