-
Notifications
You must be signed in to change notification settings - Fork 295
Create recurring event
Recurring events differ slightly in iOS and Android. The following should help guide you through the way this API handles creating recurring events for each OS. Also, be sure to understand whats necessary for creating a basic non-recurring event.
Adding a recurrence rule is simple, although it helps to understand the properties that establish the rule.
-
frequency - Controls how frequently the event will happen until its
endDate
. Eitherdaily
,weekly
,monthly
,yearly
. -
endDate - The date when the recurring events end. Note: Use this as the event end date instead of the top level event
endDate
. -
occurrence - This sets a number of occurrences for the recurring event, without needing an
endDate
. - interval - The interval between recurring events. For example an event with a weekly recurrence and interval an interval of 2 will repeat every 2 weeks.
Setting the frequency
of the event gives control over how often the event should repeat, with the following options: daily
, weekly
, monthly
, yearly
.
RNCalendarEvents.saveEvent('Title of event', {
startDate: '2016-08-19T19:26:00.000Z',
recurrenceRule: {
frequency: 'weekly',
endDate: '2017-08-19T19:26:00.000Z'
}
})
Adding an interval
controls the how often the recurrence rule repeats over time indicated by its frequency.
RNCalendarEvents.saveEvent('Title of event', {
startDate: '2016-08-19T19:26:00.000Z',
recurrenceRule: {
frequency: 'weekly',
occurrence: 52,
interval: 2,
endDate: '2017-08-19T19:26:00.000Z'
}
})
Setting the occurrence
defines the number of times an event will repeat. This help avoid explicitly needing to set an endDate
.
RNCalendarEvents.saveEvent('Title of event', {
startDate: '2016-08-19T19:26:00.000Z',
recurrenceRule: {
frequency: 'weekly',
occurrence: 52,
endDate: '2017-08-19T19:26:00.000Z'
}
})
If you do not wish the event to repeat forever, an endDate
can be defined. This is an alternative to settings an occurrence
count.
RNCalendarEvents.saveEvent('Title of event', {
startDate: '2016-08-19T19:26:00.000Z',
recurrenceRule: {
frequency: 'weekly',
endDate: '2017-08-19T19:26:00.000Z'
}
})