React Native Module for accessing and saving events to iOS and Android calendars.
npm install --save react-native-calendar-events
Check with React Native documention on linking libraries for more details.
react-native link
import RNCalendarEvents from 'react-native-calendar-events';| Property | Type | Description | iOS | Android |
|---|---|---|---|---|
| id* | String | Unique id for the calendar event. | β | β |
| calendarId** | String | Unique id for the calendar where the event will be saved. Defaults to the device's default calendar. | β | β |
| title | String | The title for the calendar event. | β | β |
| startDate | Date | The start date of the calendar event in ISO format. | β | β |
| endDate | Date | The end date of the calendar event in ISO format. | β | β |
| allDay | Bool | Indicates whether the event is an all-day event. | β | β |
| recurrence | String | The simple recurrence frequency of the calendar event daily, weekly, monthly, yearly or none. |
β | β |
| recurrenceRule ** | Object | The events recurrence settings. | β | β |
| occurrenceDate* | Date | The original occurrence date of an event if it is part of a recurring series. | β | |
| isDetached | Bool | Indicates whether an event is a detached instance of a repeating event. | β | |
| url | String | The url associated with the calendar event. | β | β |
| location | String | The location associated with the calendar event. | β | β |
| notes | String | The notes associated with the calendar event. | β | |
| description | String | The description associated with the calendar event. | β | |
| alarms | Array | The alarms associated with the calendar event, as an array of alarm objects. | β | β |
| calendar* | Object | The calendar containing the event. | β | β |
* Read only, ** Write only
| Property | Type | Description | iOS | Android |
|---|---|---|---|---|
| frequency | String | Event recurring frequency daily, weekly, monthly, yearly |
β | β |
| endDate | Date | Event recurring end date. This overrides occurrence | β | β |
| occurrence | Number | Number of event occurrences. | β | β |
| interval | Number | The interval between events of this recurrence. | β | β |
* Read only, ** Write only
| Property | Type | Description | iOS | Android |
|---|---|---|---|---|
| exceptionDate | Date | The start date of a recurring event's exception instance. Used for updating single event in a recurring series | β | β |
| futureEvents | Bool | If true the update will span all future events. If false it only update the single instance. |
β |
Get calendar authorization status.
RNCalendarEvents.authorizationStatus()Returns: Promise
- fulfilled: String -
denied,restricted,authorizedorundetermined - rejected: Error
Request calendar authorization. Authorization must be granted before accessing calendar events.
Android note: This is only necessary for targeted SDK of 23 and higher.
RNCalendarEvents.authorizeEventStore()Returns: Promise
- fulfilled: String -
denied,restricted,authorizedorundetermined - rejected: Error
Find calendar event by id. Returns a promise with fulfilled found events.
RNCalendarEvents.findEventById(id)Arguments:
- id: String - The events unique id.
Returns: Promise
- fulfilled: Object | null - Found event with unique id.
- rejected: Error
Fetch all calendar events. Returns a promise with fulfilled found events.
RNCalendarEvents.fetchAllEvents(startDate, endDate, calendars)Arguments:
- startDate: Date - The start date of the range of events fetched.
- endDate: Date - The end date of the range of events fetched.
- calendars: Array - List of calendar id strings to specify calendar events. Defaults to all calendars if empty.
Returns: Promise
- fulfilled: Array - Matched events within the specified date range.
- rejected: Error
Creates calendar event.
RNCalendarEvents.saveEvent(title, details, options);
Arguments:
- title: String - The title of the event.
- details: Object - The event's details.
- options: Object - Options specific to the saved event.
Returns: Promise
- fulfilled: String - Created event's ID.
- rejected: Error
Give the unique calendar event id to update an existing calendar event.
RNCalendarEvents.saveEvent(title, {id: 'FE6B128F-C0D8-4FB8-8FC6-D1D6BA015CDE'})
Arguments:
- title: String - The title of the event.
- details: Object - The event's details.
- options: Object - Options specific to the saved event.
Returns: Promise
- fulfilled: String - Updated event's ID.
- rejected: Error
| Property | Type | Description | iOS | Android |
|---|---|---|---|---|
| date | Date or Number | If a Date is given, an alarm will be set with an absolute date. If a Number is given, an alarm will be set with a relative offset (in minutes) from the start date. | β | β |
| structuredLocation | Object | The location to trigger an alarm. | β |
| Property | Type | Description | iOS | Android |
|---|---|---|---|---|
| title | String | The title of the location. | β | |
| proximity | String | A value indicating how a location-based alarm is triggered. Possible values: enter, leave, none. |
β | |
| radius | Number | A minimum distance from the core location that would trigger the calendar event's alarm. | β | |
| coords | Object | The geolocation coordinates, as an object with latitude and longitude properties | β |
Example with date:
RNCalendarEvents.saveEvent('title', {
location: 'location',
notes: 'notes',
startDate: '2016-08-19T19:26:00.000Z',
endDate: '2017-08-19T19:26:00.000Z',
alarms: [{
date: -1 // or absolute date - iOS Only
}]
})Example with structuredLocation (iOS Only):
RNCalendarEvents.saveEvent('title', {
location: 'location',
notes: 'notes',
startDate: '2016-08-19T19:26:00.000Z',
endDate: '2017-08-19T19:26:00.000Z',
alarms: [{
structuredLocation: {
title: 'title',
proximity: 'enter',
radius: 500,
coords: {
latitude: 30.0000,
longitude: 97.0000
}
}
}]
})Example with recurrence:
RNCalendarEvents.saveEvent('title', {
location: 'location',
notes: 'notes',
startDate: '2016-08-19T19:26:00.000Z',
endDate: '2017-08-29T19:26:00.000Z',
alarms: [{
date: -1 // or absolute date - iOS Only
}],
recurrenceRule: {
frequency: 'daily'
interval: 2,
endDate: '2017-08-29T19:26:00.000Z'
}
})Removes calendar event.
RNCalendarEvents.removeEvent(id, options)Arguments:
- id: String - The id of the event to remove.
- options: Object - Options specific to event removal.
Returns: Promise
- fulfilled: Bool - Successful
- rejected: Error
Removes future (recurring) calendar events.
RNCalendarEvents.removeFutureEvents(id)Arguments:
- id: String - The id of the event to remove.
Returns: Promise
- fulfilled: Bool - Successful
- rejected: Error
Finds all the calendars on the device.
RNCalendarEvents.findCalendars()Returns: Promise
- fulfilled: Array - A list of known calendars on the device
- rejected: Error