Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
react-native-calendar-events
Advanced tools
Changelog
2.2.0 - 2021-01-08
Fixed findEventByID
on iOS - return null if event is not found (for consistency with Android) #337 by @dstop75
Fixed android calendar query to catch events that intersect date range but aren't entirely a subset (for consistency with iOS) #333 by @jenniferburch
Added ability to set timezone on events in iOS (necessary for recurrence expansion to work correctly across daylight savings time transitions) #335 by @LorienHW and @mcarlson
Also includes minor documentation tweaks.
Readme
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.
version | react-native version |
---|---|
2.0.0+ | 0.60.0+ |
pre 2.0.0+ | 0.40.0+ |
For 0.59-, you should use jetify -r
$ npm install --save react-native-calendar-events
# --- or ---
$ yarn add react-native-calendar-events
Don't forget going into the ios
directory to execute a pod install
.
Because this package targets React Native 0.60.0+, you will probably don't need to link it manually. Otherwise if it's not the case, follow this additional instructions:
Add this line to your ios/Podfile
file, then run pod install
.
target 'YourAwesomeProject' do
# β¦
pod 'RNCalendarEvents', :path => '../node_modules/react-native-calendar-events'
end
1 - Add the following lines to android/settings.gradle
:
include ':react-native-calendar-events'
project(':react-native-calendar-events').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-calendar-events/android')
2 - Add the implementation line to the dependencies in android/app/build.gradle
:
dependencies {
// ...
implementation project(':react-native-calendar-events')
}
3 - Add the import and link the package in MainApplication.java
:
import com.calendarevents.RNCalendarEventsPackage; // <- add the RNCalendarEventsPackage import
public class MainApplication extends Application implements ReactApplication {
// β¦
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// β¦
packages.add(new RNCalendarEventsPackage());
return packages;
}
// β¦
}
Add RNCalendarEvents
, as well as EventKit.framework
to project libraries if not already done.
Setting up privacy usage descriptions may also be required depending on which iOS version is supported. This involves updating the Property List, Info.plist
, with the corresponding key for the EKEventStore api. Info.plist reference.
For updating the Info.plist
key/value via XCode, add a Privacy - Calendars Usage Description
key with a usage description as the value. Resulting change to Info.plist
should look something like:
<key>NSCalendarsUsageDescription</key>
<string>This app requires access to the calendar</string>
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";
checkPermissions
Get calendar authorization status. You may check for the default read/write access with no argument, or read-only access on Android by passing boolean true. iOS is always read/write.
RNCalendarEvents.checkPermissions((readOnly = false));
Returns: Promise
denied
, restricted
, authorized
or undetermined
requestPermissions
Request calendar authorization. Authorization must be granted before accessing calendar events.
RNCalendarEvents.requestPermissions((readOnly = false));
(readOnly is for Android only, see below)
Android note: this is necessary for targeted SDK of >=23. iOS note: This method will crash, if you didn't update
Info.plist
. Follow carefully installation instruction.
Returns: Promise
denied
, restricted
, authorized
or undetermined
requestPermissions
(Android only)β οΈ Note that to restrict to read-only usage on Android (iOS is always read/write) you will need to alter the included Android permissions
as the AndroidManifest.xml
is merged during the Android build.
You do that by altering your AndroidManifest.xml to "remove" the WRITE_CALENDAR permission with an entry like so:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
>
<!-- ... -->
<uses-permission tools:node="remove" android:name="android.permission.WRITE_CALENDAR" />
findCalendars
Finds all the calendars on the device.
RNCalendarEvents.findCalendars();
Returns: Promise
saveCalendar
Create a calendar.
RNCalendarEvents.saveCalendar(calendar);
β οΈ When you want to save a calendar, you need to use a valid source (find using findCalendars
).
Arguments:
Returns: Promise
removeCalendar
Removes a calendar.
RNCalendarEvents.removeCalendar(id);
Arguments:
Returns: Promise
findEventById
Find calendar event by id. Returns a promise with fulfilled found events.
RNCalendarEvents.findEventById(id);
Arguments:
Returns: Promise
fetchAllEvents
Fetch all calendar events. Returns a promise with fulfilled found events.
RNCalendarEvents.fetchAllEvents(startDate, endDate, calendars);
Arguments:
Returns: Promise
saveEvent
Creates or updates a calendar event. - wiki guide
RNCalendarEvents.saveEvent(title, details, options);
Arguments:
Returns: Promise
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:
Returns: Promise
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 | β | |
timeZone | String | The time zone associated with the event | β |
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
These are some common issues you may run into while using react-native-calendar-events
library.
If you encounter something that is not listed here, try searching in GitHub issues of react-native-calendar-events
.
This might be related to a sync issue. You need to be sure that the event you saved is matching what your device will keep in sync.
For iOS, you might have not all event synced. You might need to update this iOS settings in Settings > Calendar > Sync > All Events. If that's not enough, it might be worth checking iOS iCloud sync documentation.
For Android, you can have a look to Google Calendar sync problems documentation.
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!
FAQs
React Native module for IOS Calendar Events
The npm package react-native-calendar-events receives a total of 47,242 weekly downloads. As such, react-native-calendar-events popularity was classified as popular.
We found that react-native-calendar-events demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.Β It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.