CapacitorCalendar
This CapacitorJS plugin simplifies the process of managing calendar events within your hybrid mobile applications.
With CRUD functionalities (Create, Read, Update, Delete), you can seamlessly interact with the device's native
calendar directly from your app.
https://capacitor-calendar.pages.dev
Table of Contents
Install
npm install @ebarooni/capacitor-calendar
npx cap sync
Support Range
Platform | range |
---|
iOS | ≥ 13 |
Android | ≥ 4 (SDK 14 – Ice Cream Sandwich) |
iOS 17 | Android 14 |
---|
 |  |
On iOS, readCalendar
permission is not needed when you are creating an event using the native prompt.
The video is just for showing the functionality, otherwise the createEventWithPrompt
method works without the readCalendar
authorization.
MVP
- ✅ Choose calendars with prompt (only supported on iOS)
- ✅ Get list of available calendars
- ✅ Get default calendar
- ⌛ Create calendar events without native prompts
- ⌛️ Create reminders (only supported on iOS)
- ⌛️ Find calendar events
- ⌛️ Delete calendar events
Permissions
To be able to use the plugin, you will need to add the required permissions to your app. The required platform-specific
permissions can be found below:
API
checkPermission(...)
checkPermission(options: { alias: keyof CalendarPermissionStatus; }) => Promise<{ result: PermissionState; }>
Checks the current authorization status of a specific permission.
Returns: Promise<{ result: PermissionState; }>
checkAllPermissions()
checkAllPermissions() => Promise<CalendarPermissionStatus>
Checks the current authorization status of all the required permissions for the plugin.
Returns: Promise<CalendarPermissionStatus>
requestPermission(...)
requestPermission(options: { alias: keyof CalendarPermissionStatus; }) => Promise<{ result: PermissionState; }>
Requests authorization to a specific permission, if not already granted.
If the permission is already granted, it will directly return the status.
Returns: Promise<{ result: PermissionState; }>
requestAllPermissions()
requestAllPermissions() => Promise<CalendarPermissionStatus>
Requests authorization to all the required permissions for the plugin, if they have not already been granted.
Returns: Promise<CalendarPermissionStatus>
createEventWithPrompt()
createEventWithPrompt() => Promise<{ eventCreated: boolean; }>
Creates an event in the calendar by using the native calendar.
On iOS opens a native sheet and on Android opens an intent.
This method does not need any read or write authorization from the user on iOS. However, the entries in the Info.plist file are still needed.
On Android, the user has to authorize for read access.
Returns: Promise<{ eventCreated: boolean; }>
selectCalendarsWithPrompt(...)
selectCalendarsWithPrompt(options: { displayStyle: CalendarChooserDisplayStyle; selectionStyle: CalendarChooserSelectionStyle; }) => Promise<{ result: Calendar[]; }>
Presents a prompt to the user to select calendars. This method is available only on iOS.
Returns: Promise<{ result: Calendar[]; }>
listCalendars()
listCalendars() => Promise<{ result: Calendar[]; }>
Retrieves a list of calendars available on the device.
Returns: Promise<{ result: Calendar[]; }>
getDefaultCalendar()
getDefaultCalendar() => Promise<{ result: Calendar; }>
Retrieves the default calendar set on the device.
Returns: Promise<{ result: Calendar; }>
Interfaces
CalendarPermissionStatus
Describes the permission status for reading from the calendar.
Calendar
Represents a calendar object with an ID and title.
Prop | Type |
---|
id | string |
title | string |
Type Aliases
PermissionState
'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'
Enums
CalendarChooserDisplayStyle
Members | Description |
---|
ALL_CALENDARS | Display all calendars available for selection. |
WRITABLE_CALENDARS_ONLY | Display only writable calendars available for selection. |
CalendarChooserSelectionStyle
Members | Description |
---|
SINGLE | Allows only a single selection in the calendar chooser. |
MULTIPLE | Allows multiple selections in the calendar chooser. |