Skip to main content

Calendar

The Calendar plugin allows you to add events to the system calendar of the mobile device.

Installation#

If you have not already setup Ionic Enterprise in your app, follow the one-time setup steps.

Next, install the plugin:

npm install @ionic-enterprise/calendar
npx cap sync

Index#

Classes#

Interfaces#


Classes#

Calendar#

Calendar:

name: Calendar

description: This plugin allows you to add events to the Calendar of the mobile device.

usage:

import { Calendar } from '@ionic-enterprise/calendar/ngx';
constructor(private calendar: Calendar) { }
this.calendar.createCalendar('MyCalendar').then(
(msg) => { console.log(msg); },
(err) => { console.log(err); }
);

interfaces: CalendarOptions NameOrOptions

createCalendar#

createCalendar(nameOrOptions: string | NameOrOptions): Promise<any>

Create a calendar. (iOS only)

Parameters:

NameTypeDescription
nameOrOptionsstring | NameOrOptionseither a string name or a options object. If string, provide the calendar name. IF an object, provide a calendar name as a string and a calendar color in hex format as a string

Returns: Promise<any> Returns a Promise


createEvent#

createEvent(title?: string, location?: string, notes?: string, startDate?: Date, endDate?: Date): Promise<any>

Silently create an event.

Parameters:

NameType
Optional titlestring
Optional locationstring
Optional notesstring
Optional startDateDate
Optional endDateDate

Returns: Promise<any> Returns a Promise


createEventInteractively#

createEventInteractively(title?: string, location?: string, notes?: string, startDate?: Date, endDate?: Date): Promise<any>

Interactively create an event.

Parameters:

NameType
Optional titlestring
Optional locationstring
Optional notesstring
Optional startDateDate
Optional endDateDate

Returns: Promise<any> Returns a Promise


createEventInteractivelyWithOptions#

createEventInteractivelyWithOptions(title?: string, location?: string, notes?: string, startDate?: Date, endDate?: Date, options?: CalendarOptions): Promise<any>

Interactively create an event with additional options.

Parameters:

NameType
Optional titlestring
Optional locationstring
Optional notesstring
Optional startDateDate
Optional endDateDate
Optional optionsCalendarOptions

Returns: Promise<any>


createEventWithOptions#

createEventWithOptions(title?: string, location?: string, notes?: string, startDate?: Date, endDate?: Date, options?: CalendarOptions): Promise<any>

Silently create an event with additional options.

Parameters:

NameType
Optional titlestring
Optional locationstring
Optional notesstring
Optional startDateDate
Optional endDateDate
Optional optionsCalendarOptions

Returns: Promise<any> Returns a Promise


deleteCalendar#

deleteCalendar(name: string): Promise<any>

Delete a calendar. (iOS only)

Parameters:

NameTypeDescription
namestringName of the calendar to delete.

Returns: Promise<any> Returns a Promise


deleteEvent#

deleteEvent(title?: string, location?: string, notes?: string, startDate?: Date, endDate?: Date): Promise<any>

Delete an event.

Parameters:

NameType
Optional titlestring
Optional locationstring
Optional notesstring
Optional startDateDate
Optional endDateDate

Returns: Promise<any> Returns a Promise


deleteEventById#

deleteEventById(id: string, fromDate?: Date): Promise<any>

Delete an event by id.

Parameters:

NameType
idstring
Optional fromDateDate

Returns: Promise<any> Returns a Promise


deleteEventFromNamedCalendar#

deleteEventFromNamedCalendar(title?: string, location?: string, notes?: string, startDate?: Date, endDate?: Date, calendarName?: string): Promise<any>

Delete an event from the specified Calendar. (iOS only)

Parameters:

NameTypeDescription
Optional titlestring
Optional locationstring
Optional notesstring
Optional startDateDate
Optional endDateDate
Optional calendarNamestring-

Returns: Promise<any> Returns a Promise


findAllEventsInNamedCalendar#

findAllEventsInNamedCalendar(calendarName: string): Promise<any>

Get a list of all future events in the specified calendar. (iOS only)

Parameters:

NameType
calendarNamestring

Returns: Promise<any> Returns a Promise that resolves with the list of events, or rejects with an error.


findEvent#

findEvent(title?: string, location?: string, notes?: string, startDate?: Date, endDate?: Date): Promise<any>

Find an event.

Parameters:

NameType
Optional titlestring
Optional locationstring
Optional notesstring
Optional startDateDate
Optional endDateDate

Returns: Promise<any>


findEventWithOptions#

findEventWithOptions(title?: string, location?: string, notes?: string, startDate?: Date, endDate?: Date, options?: CalendarOptions): Promise<any>

Find an event with additional options.

Parameters:

NameType
Optional titlestring
Optional locationstring
Optional notesstring
Optional startDateDate
Optional endDateDate
Optional optionsCalendarOptions

Returns: Promise<any> Returns a Promise that resolves with the event, or rejects with an error.


getCalendarOptions#

getCalendarOptions(): CalendarOptions

Returns the default calendar options.

Returns: CalendarOptions Returns an object with the default calendar options


getCreateCalendarOptions#

getCreateCalendarOptions(): NameOrOptions

Returns options for a custom calender with specific color

Returns: NameOrOptions Returns an object with the default options


hasReadPermission#

hasReadPermission(): Promise<boolean>

Check if we have read permission

Returns: Promise<boolean>


hasReadWritePermission#

hasReadWritePermission(): Promise<boolean>

This function checks if we have permission to read/write from/to the calendar. The promise will resolve with true when:

  • You're running on iOS, or
  • You're targeting API level lower than 23, or
  • You're using Android < 6, or
  • You've already granted permission

If this returns false, you should call the requestReadWritePermission function

Returns: Promise<boolean>


hasWritePermission#

hasWritePermission(): Promise<boolean>

Check if we have write permission

Returns: Promise<boolean>


listCalendars#

listCalendars(): Promise<any>

Get a list of all calendars.

Returns: Promise<any> A Promise that resolves with the list of calendars, or rejects with an error.


listEventsInRange#

listEventsInRange(startDate: Date, endDate: Date): Promise<any>

Find a list of events within the specified date range. (Android only)

Parameters:

NameType
startDateDate
endDateDate

Returns: Promise<any> Returns a Promise that resolves with the list of events, or rejects with an error.


modifyEvent#

modifyEvent(title?: string, location?: string, notes?: string, startDate?: Date, endDate?: Date, newTitle?: string, newLocation?: string, newNotes?: string, newStartDate?: Date, newEndDate?: Date): Promise<any>

Modify an event. (iOS only)

Parameters:

NameType
Optional titlestring
Optional locationstring
Optional notesstring
Optional startDateDate
Optional endDateDate
Optional newTitlestring
Optional newLocationstring
Optional newNotesstring
Optional newStartDateDate
Optional newEndDateDate

Returns: Promise<any> Returns a Promise


modifyEventWithOptions#

modifyEventWithOptions(title?: string, location?: string, notes?: string, startDate?: Date, endDate?: Date, newTitle?: string, newLocation?: string, newNotes?: string, newStartDate?: Date, newEndDate?: Date, filterOptions?: CalendarOptions, newOptions?: CalendarOptions): Promise<any>

Modify an event with additional options. (iOS only)

Parameters:

NameType
Optional titlestring
Optional locationstring
Optional notesstring
Optional startDateDate
Optional endDateDate
Optional newTitlestring
Optional newLocationstring
Optional newNotesstring
Optional newStartDateDate
Optional newEndDateDate
Optional filterOptionsCalendarOptions
Optional newOptionsCalendarOptions

Returns: Promise<any> Returns a Promise


openCalendar#

openCalendar(date: Date): Promise<any>

Open the calendar at the specified date.

Parameters:

NameTypeDescription
dateDateThe date you want to open the calendar on

Returns: Promise<any> Promise returns a promise


requestReadPermission#

requestReadPermission(): Promise<any>

Request read permission

Returns: Promise<any>


requestReadWritePermission#

requestReadWritePermission(): Promise<any>

Requests read/write permissions

Returns: Promise<any>


requestWritePermission#

requestWritePermission(): Promise<any>

Request write permission

Returns: Promise<any>



Interfaces#

CalendarOptions#

CalendarOptions:

<Optional> calendarId#

● calendarId: number

Calendar id


<Optional> calendarName#

● calendarName: string

Calendar name. Ths is supported by iOS only.


<Optional> firstReminderMinutes#

● firstReminderMinutes: number


<Optional> id#

● id: string

Id


<Optional> recurrence#

● recurrence: string

Recurrence. Can be set to daily, weekly, monthly or yearly


<Optional> recurrenceEndDate#

● recurrenceEndDate: Date

Recurrence end date. Valid only when recurrence option is set.


<Optional> recurrenceInterval#

● recurrenceInterval: number

Recurrence interval. Valid only when recurrence option is set.


<Optional> secondReminderMinutes#

● secondReminderMinutes: number


<Optional> url#

● url: string

URL



NameOrOptions#

NameOrOptions:

<Optional> calendarColor#

● calendarColor: string

Calendar color as a HEX string


<Optional> calendarName#

● calendarName: string

Calendar name