-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Feat: Allow for repeat to specify amount of the given repeat type (Android) #2030
Conversation
Fixed typos
This allows repeat interval to be configured as following "Every 3 days": {repeatType: "day", repeatTime: 3} "Every 2 weeks": {repeatType: "week", repeatTime: 2}
README.md
Outdated
@@ -324,6 +324,7 @@ PushNotification.localNotification({ | |||
ignoreInForeground: false, // (optional) if true, the notification will not be visible when the app is in the foreground (useful for parity with how iOS notifications appear). should be used in combine with `com.dieam.reactnativepushnotification.notification_foreground` setting | |||
shortcutId: "shortcut-id", // (optional) If this notification is duplicative of a Launcher shortcut, sets the id of the shortcut, in case the Launcher wants to hide the shortcut, default undefined | |||
onlyAlertOnce: false, // (optional) alert will open only once with sound and notify, default: false | |||
repeatTime: 1, // (optional) Increment of configured repeateType. Check 'Repeating Notifications' section for more info. |
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.
Hi @johgusta
This line should not be documented there, it's on the scheduldedNotification method 😉
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.
I might have misunderstood this, but I think repeating is possible for both the localNotification
and localNotificationSchedule
functions. Since this one has the documentation for repeatType: 'day'
I thought this would be the right place to add this info. In my project we only use localNotificationSchedule
though but as far as I can tell it should still work for both.
...id/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java
Outdated
Show resolved
Hide resolved
Hi @johgusta |
Thanks for the review! I've updated the code and I think the documentation is correct as it is, but let me know if I've misunderstood that and I'll fix it. |
Ok! I will update the documentation and move it to the the scheduled notification section then. |
Thanks for your contribution ! |
Problem
We want our local notifications to be able to repeat every other day, and it is critical that the time of day is correct. Currently the closest possible setting would be to use
repeatType: 'time'
and then calculate the milliseconds for two days and set it asrepeatTime
. For a repeating reminder this will change the time of day the reminder repeats when daylight saving changes the UTC offset.Solution
Since the library already allows
repeatTime
fortime
, this PR will update it to allowrepeatTime
for all the repeat types. Instead of calculating the milliseconds of each type we're using theCalendar.add()
function with the corresponding field. The amount to increase it by is set byrepeatTime
and defauls to 1. It also follows the same logic as already implemented for repeating on months.Example of how to repeat every other day: