Skip to content

alexei-sevrukov-topx/react-native-calendar-events

Β 
Β 

Repository files navigation

React Native Calendar Events

npm npm npm

A React Native module to help access and save events to iOS and Android calendars.

Table of contents

Getting started

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.

Step 1. - Install

Install the react-native-calendar-events library with native code.

npm install --save react-native-calendar-events

Step 2. - Link the library

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.

Step 3. - OS specific setup


API

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';

authorizationStatus

Get calendar authorization status.

RNCalendarEvents.authorizationStatus()

Returns: Promise

  • fulfilled: String - denied, restricted, authorized or undetermined
  • rejected: Error

authorizeEventStore

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 or undetermined
  • rejected: Error

findCalendars

Finds all the calendars on the device.

RNCalendarEvents.findCalendars()

Returns: Promise

  • fulfilled: Array - A list of known calendars on the device
  • rejected: Error

saveCalendar

Create a calendar.

RNCalendarEvents.saveCalendar(calendar)

Arguments:

  • calendar: Object - Calendar to create.

Returns: Promise

  • fulfilled: The id of the created calendar
  • rejected: Error

findEventById

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

fetchAllEvents

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

saveEvent

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'})

removeEvent

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

Event fields

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 βœ“

Calendar

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. βœ“ βœ“

Attendees

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. βœ“

Recurrence rule

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. βœ“ βœ“

Alarms

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. βœ“

Alarm structuredLocation

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 βœ“

Options

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. βœ“

Calendar options

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


Wiki

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • Big thanks to all who have contributed, raised an issue or simply find use in this project. Cheers!

About

πŸ“† React Native Module for iOS and Android Calendar Events

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 57.1%
  • Objective-C 39.7%
  • JavaScript 2.6%
  • Ruby 0.6%