A React Native module to help access and save events to iOS and Android calendars.
This package assumes that you already have a React Native project or are familiar with React Native. If not, checkout the official documentation for more details about getting started with React Native.
The following is required for the package to work properly.
Install the react-native-calendar-events
library with native code.
npm install --save react-native-calendar-events
Since this package contains native code, you will need to include the code as a library. The React Native documentation on "Linking Libraries" also provides some details for this process.
- Automatic linking
react-native link
- Manual linking
Sometimes "automatic linking" is not sufficient or is not properly including the library. Fortunately, the React Native docs on "Manual Linking" serves a helpful guide (with pictures) in the process.
-
iOS specific instructions
iOS specific requirements, such as mandatory privacy usage descriptions and including theEventKit.framework
. -
Android specific instructions
Android specific requirements, such as mandatory application permissions.
The following API allows for interacting with both iOS and Android device calendars. See the full list of available event fields.
import RNCalendarEvents from 'react-native-calendar-events';
Get calendar authorization status.
RNCalendarEvents.authorizationStatus()
Returns: Promise
- fulfilled: String -
denied
,restricted
,authorized
orundetermined
- 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
,authorized
orundetermined
- 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
Create a calendar.
RNCalendarEvents.saveCalendar(calendar)
Arguments:
- calendar: Object - Calendar to create.
Returns: Promise
- fulfilled: The id of the created calendar
- rejected: Error
Removes a calendar.
RNCalendarEvents.removeCalendar(id)
Arguments:
- id: String - The id of the calendar to remove.
Returns: Promise
- fulfilled: Bool - Successful
- 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: String - The start date of the range of events fetched.
- endDate: String - 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 or updates a calendar event. - wiki guide
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
To update an event, the event id
must be defined. - wiki guide
RNCalendarEvents.saveEvent(title, {id: 'FE6B128F-C0D8-4FB8-8FC6-D1D6BA015CDE'})
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
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 | String | The start date of the calendar event in ISO format. | β | β |
endDate | String | 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* | String | 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. | β | β |
attendees* | Array | The attendees of the event, including the organizer. | β | β |
calendar* | Object | The calendar containing the event. | β | β |
skipAndroidTimezone | Bool | Skip the process of setting automatic timezone on android | β |
Property | Type | Description | iOS | Android |
---|---|---|---|---|
id | String | Unique calendar ID. | β | β |
title | String | The calendarβs title. | β | β |
type | String | The calendarβs type. | β | β |
source | String | The source object representing the account to which this calendar belongs. | β | β |
isPrimary* | Bool | Indicates if the calendar is assigned as primary. | β | β |
allowsModifications* | Bool | Indicates if the calendar allows events to be written, edited or removed. | β | β |
color* | String | The color assigned to the calendar represented as a hex value. | β | β |
allowedAvailabilities* | Array | The event availability settings supported by the calendar. | β | β |
Property | Type | Description | iOS | Android |
---|---|---|---|---|
name | String | The name of the attendee. | β | β |
email* | String | The email address of the attendee. | β | β |
phone* | String | The phone number of the attendee. | β |
Property | Type | Description | iOS | Android |
---|---|---|---|---|
frequency | String | Event recurring frequency. Allowed values are daily , weekly , monthly , yearly . |
β | β |
endDate | String | Event recurring end date. This overrides occurrence. | β | β |
occurrence | Number | Number of event occurrences. | β | β |
interval | Number | The interval between events of this recurrence. | β | β |
Property | Type | Description | iOS | Android |
---|---|---|---|---|
date | String or Number | If a String 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 | β |
Property | Type | Description | iOS | Android |
---|---|---|---|---|
exceptionDate | String | 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. |
β |
Property | Type | Description | iOS | Android |
---|---|---|---|---|
title | String | The calendar title (required) | β | β |
color | String | The calendar color (required) | β | β |
entityType | String | 'event' or 'reminder' (required) | β | |
name | String | The calendar name (required) | β | |
accessLevel | String | Defines how the event shows up for others when the calendar is shared doc(required) 'contributor', 'editor', 'freebusy', 'override', 'owner', 'read', 'respond', 'root' |
β | |
ownerAccount | String | The owner account for this calendar, based on the calendar feed doc(required) | β | |
source | Object | The calendar Account source (required) | β | |
source.name | String | The Account name (required) | β | |
source.type | String | The Account type | β | |
source.isLocalAccount | Bool | The source (required if source.type is not used) | β |
* Read only, ** Write only
- Will McMahan - Initial code - github.com/wmcmahan
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details
- Big thanks to all who have contributed, raised an issue or simply find use in this project. Cheers!