Skip to content

Creating basic event

Will McMahan edited this page Mar 20, 2018 · 2 revisions

Creating events is fairly straightforward. Hopefully the following explanation can help.

Basic

For both iOS and Android the pattern is simple; the event needs a title as well as a startDate and endDate. The endDate should also be a date later than the startDate.

RNCalendarEvents.saveEvent('Title of event', {
  startDate: '2016-08-19T19:26:00.000Z',
  endDate: '2017-08-19T19:26:00.000Z'
}) 

Specify a calendar

The example above will simply save the event to your devices default calendar. If you wish to control which calendar the event is saved to, you must provide the calendarId. This will ensure your event is saved to an expected calendar.

RNCalendarEvents.saveEvent('Title of event', {
  calendarId: '141',
  startDate: '2016-08-19T19:26:00.000Z',
  endDate: '2017-08-19T19:26:00.000Z'
}) 

Additional fields

There are also other writable fields available. For example, you may wish to specify the location of the event or add additional notes for the event. Complete list of fields can be found here.

RNCalendarEvents.saveEvent('Title of event', {
  calendarId: '141',
  startDate: '2016-08-19T19:26:00.000Z',
  endDate: '2017-08-19T19:26:00.000Z',
  location: 'Los Angeles, CA',
  notes: 'Bring sunglasses'
}) 
Clone this wiki locally