-
Notifications
You must be signed in to change notification settings - Fork 291
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
Add ability to repeat notifications like on iOS #268
Add ability to repeat notifications like on iOS #268
Conversation
Any update on getting this into the build? I am working on a project where we need access to weekly repeat intervals. I would prefer to be able to schedule notifications locally rather than needing to rely on internet connection to compensate with a server backend. Thanks! |
I personnaly ended up with my personal repo, for my own needs while the maintainers are not available. The package is perfectly working on my app fyi, with the notifications displayed at the correct time and hour. The code modification is really small, so you can easily drop it when the bug will be fixed in the future. |
Thank you so much @ghivert ! |
Any update on getting this into the build? @Dallas62 @Naturalclar |
Hi, |
Pinging this again - I want to use this for my app. Can one of the maintainers approve this change? @Naturalclar? |
@Dallas62 Hi, My idea was to mimic the behavior provided by iOS in this package, because we're only dealing with iOS and it would be too bad to ignore some features because of some reasons. You can easily write a wrapper talking both to iOS and Android with this package as foundation. Of course I'm open to debate, but I think keeping this feature as a wrapper is better than providing a custom solution: I really don't know the different use cases for notifications and it's probably easy to forget about some users.
@smadan The package hadn't changed since I wrote the PR, so you can probably use |
I agree that nanoseconds are not really necessary as there really shouldnt be any situations where you're emitting notification events in nanosecond intervals. On your comment about month and hour. I agree somewhat, but if you're thinking logistically about it, it is possible to have a notification go off at specific hours but not recast that notification by the month. For example if you cast by Month and Hour there might be situations where your notifications do not emit at the expected time. However all of these things are edge cases that can easily be avoided with some very lightweight code. However I see what the original PR creator was trying to do, I have done some digging myself into IOS notifications and they did mimic how IOS's OS handles notifications which I can respect (keeping the fundamentals the same that is). I do not disagree that we can optimize the code here though. @Dallas62 Do you plan on use this PR for your notification library? I was having an issue with repeating notifications and had planned to manually change your own Package to use this fork (or a similar edit). Repeating intervals is somewhat important for timers and such. |
So I wish I has come across this PR before I spent the time on implementing much the same thing... I just submitted a PR recently #308. Your approach seems to be a bit more configurable, I just sought to replicate the repeatInterval functionality that is available in scheduleLocalNotification(). |
You should probably also add in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall I think this is good. My suggestions would be to also allow repeating by year and dayOfWeek, but to remove nanosecond. Even if nanosecond repeats are supported in iOS, I'm not sure if this library should support it.
- `sound` : The sound played when the notification is fired. | ||
- `category` : The category of this notification, required for actionable notifications. | ||
- `isSilent` : If true, the notification will appear without sound. | ||
- `userInfo` : An object containing additional notification data. | ||
|
||
request.repeatsComponent is an object containing (each field is optionnal): | ||
|
||
- `month`: Will repeat every selected month in your fireDate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest adding year component.
request.repeatsComponent is an object containing (each field is optionnal): | ||
|
||
- `month`: Will repeat every selected month in your fireDate. | ||
- `day`: Will repeat every selected day in your fireDate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest adding dayOfWeek component
- `hour`: Will repeat every selected hour in your fireDate. | ||
- `minute`: Will repeat every selected minute in your fireDate. | ||
- `second`: Will repeat every selected second in your fireDate. | ||
- `nanosecond`: Will repeat every selected nanosecond in your fireDate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest removing nanosecond
NSCalendarUnitHour | | ||
NSCalendarUnitMinute | | ||
NSCalendarUnitSecond; | ||
NSCalendarUnit repeatDateComponents = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest addition of NSCalendarUnitYear and NSCalendarUnitWeekday.
Suggest removal of NSCalendarUnitNanosecond.
* Must be used with repeats and fireDate. | ||
*/ | ||
repeatsComponent?: { | ||
month?: boolean, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest addition of year and dayOfWeek. Suggest removal of nanosecond.
@ghivert @jamesxabregas This would be a great addition, and would love to merge this in.
I agree that nanosecond should be removed as well |
Hi, |
No rush 😁 |
@ghivert Thanks so much!!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ghivert thanks so much for the change!
I will apply suggestion from @jamesxabregas in a separate PR and publish a new version.
…tification#268) Co-authored-by: Jesse Katsumata <jesse.katsumata@gmail.com> Co-authored-by: Jesse Katsumata <niconico.clarinet@gmail.com>
Hi,
Today the repeats option does not work. This PR fix this, and add the ability to freely choose the repeating interval, like asking in #263.
The idea is rather simple: let the user choose how they want to repeat the notifications with a
repeatsComponent
field in the request, and converting the components toNSCalendarUnit
to have the exact same behavior in JS than what we have in Objective-C.In case there’s no repeats, then the old behavior is used, with the same
NSCalendarUnit
to ensure the notification will be sent at the correct date.Tell me if it suits you. If not, I would be happy to fix what you want. :)