Calendar

Improve this doc

$ ionic plugin add cordova-plugin-calendar

Repo: https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin

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

Requires Cordova plugin: cordova-plugin-calendar. For more info, please see the Calendar plugin docs.

Supported platforms

Usage

import {Calendar} from 'ionic-native';



Calendar.createCalendar('MyCalendar').then(
  (msg) => { console.log(msg); },
  (err) => { console.log(err); }
);

Static Members

hasReadWritePermission()

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 targetting 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>

hasReadPermission()

Check if we have read permission

Returns: Promise<boolean>

hasWritePermission()

Check if we have write permission

Returns: Promise<boolean>

requestWritePermission()

Request write permission

Returns: Promise<any>

requestReadPermission()

Request read permission

Returns: Promise<any>

requestReadWritePermission()

Requests read/write permissions

Returns: Promise<any>

createCalendar(nameOrOptions)

Create a calendar. (iOS only)

Param Type Details
nameOrOptions string|Object

either 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

deleteCalendar(name)

Delete a calendar. (iOS only)

Param Type Details
name string

Name of the calendar to delete.

Returns: Promise<any> Returns a Promise

getCalendarOptions()

Returns the default calendar options.

Returns: CalendarOptions Returns an object with the default calendar options

createEvent(title, location, notes, startDate, endDate)

Silently create an event.

Param Type Details
title string

The event title

location string

The event location

notes string

The event notes

startDate Date

The event start date

endDate Date

The event end date

Returns: Promise<any> Returns a Promise

createEventWithOptions(title, location, notes, startDate, endDate, options)

Silently create an event with additional options.

Param Type Details
title string

The event title

location string

The event location

notes string

The event notes

startDate Date

The event start date

endDate Date

The event end date

options CalendarOptions

Additional options, see getCalendarOptions

Returns: Promise<any> Returns a Promise

createEventInteractively(title, location, notes, startDate, endDate)

Interactively create an event.

Param Type Details
title string

The event title

location string

The event location

notes string

The event notes

startDate Date

The event start date

endDate Date

The event end date

Returns: Promise<any> Returns a Promise

createEventInteractivelyWithOptions(title, location, notes, startDate, endDate, options)

Interactively create an event with additional options.

Param Type Details
title string

The event title

location string

The event location

notes string

The event notes

startDate Date

The event start date

endDate Date

The event end date

options CalendarOptions

Additional options, see getCalendarOptions

Returns: Promise<any>

findEvent(title, location, notes, startDate, endDate)

Find an event.

Param Type Details
title string

The event title

location string

The event location

notes string

The event notes

startDate Date

The event start date

endDate Date

The event end date

Returns: Promise<any>

findEventWithOptions(title, location, notes, startDate, endDate, options)

Find an event with additional options.

Param Type Details
title string

The event title

location string

The event location

notes string

The event notes

startDate Date

The event start date

endDate Date

The event end date

options CalendarOptions

Additional options, see getCalendarOptions

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

listEventsInRange(startDate, endDate)

Platforms: Android 

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

Param Type Details
startDate Date

The start date

endDate Date

The end date

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

listCalendars()

Get a list of all calendars.

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

findAllEventsInNamedCalendar()

Platforms: iOS 

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

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

modifyEvent(title, location, notes, startDate, endDate, newTitle, newLocation, newNotes, newStartDate, newEndDate)

Platforms: iOS 

Modify an event. (iOS only)

Param Type Details
title string

The event title

location string

The event location

notes string

The event notes

startDate Date

The event start date

endDate Date

The event end date

newTitle string

The new event title

newLocation string

The new event location

newNotes string

The new event notes

newStartDate Date

The new event start date

newEndDate Date

The new event end date

Returns: Returns a Promise

modifyEventWithOptions(title, location, notes, startDate, endDate, newTitle, newLocation, newNotes, newStartDate, newEndDate, filterOptions, newOptions)

Platforms: iOS 

Modify an event with additional options. (iOS only)

Param Type Details
title string

The event title

location string

The event location

notes string

The event notes

startDate Date

The event start date

endDate Date

The event end date

newTitle string

The new event title

newLocation string

The new event location

newNotes string

The new event notes

newStartDate Date

The new event start date

newEndDate Date

The new event end date

filterOptions CalendarOptions

Event Options, see getCalendarOptions

newOptions CalendarOptions

New event options, see getCalendarOptions

Returns: Returns a Promise

deleteEvent(title, location, notes, startDate, endDate)

Delete an event.

Param Type Details
title string

The event title

location string

The event location

notes string

The event notes

startDate Date

The event start date

endDate Date

The event end date

Returns: Returns a Promise

deleteEventFromNamedCalendar(title, location, notes, startDate, endDate, calendarName)

Platforms: iOS 

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

Param Type Details
title string

The event title

location string

The event location

notes string

The event notes

startDate Date

The event start date

endDate Date

The event end date

calendarName string

Returns: Returns a Promise

openCalendar(date)

Open the calendar at the specified date.

Param Type Details
date Date

The date you want to open the calendar on

Returns: Promise<any> Promise returns a promise

CalendarOptions

Param Type Details
id
(optional)
string

Id

firstReminderMinutes
(optional)
number
secondReminderMinutes
(optional)
number
recurrence
(optional)
string

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

recurrenceInterval
(optional)
number

Recurrence interval. Valid only when recurrence option is set.

recurrenceEndDate
(optional)
Date

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

calendarName
(optional)
string

Calendar name. Ths is supported by iOS only.

calendarId
(optional)
number

Calendar id

url
(optional)
string

URL

API

Native

General