Files
awesome-cordova-plugins/src/@ionic-native/plugins/calendar/index.ts
T

425 lines
11 KiB
TypeScript
Raw Normal View History

import { Injectable } from '@angular/core';
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core';
2016-07-08 00:40:35 +02:00
2016-02-08 16:11:40 -06:00
export interface CalendarOptions {
2016-12-06 08:02:00 -05:00
/**
* Id
*/
id?: string;
2016-12-06 08:02:00 -05:00
/**
*
*/
2016-02-08 16:11:40 -06:00
firstReminderMinutes?: number;
2016-12-06 08:02:00 -05:00
/**
*
*/
2016-02-08 16:11:40 -06:00
secondReminderMinutes?: number;
2016-12-06 08:02:00 -05:00
/**
* Recurrence. Can be set to `daily`, `weekly`, `monthly` or `yearly`
*/
recurrence?: string;
2016-12-06 08:02:00 -05:00
/**
* Recurrence interval. Valid only when `recurrence` option is set.
*/
recurrenceInterval?: number;
2016-12-06 08:02:00 -05:00
/**
* Recurrence end date. Valid only when `recurrence` option is set.
*/
2016-02-08 16:11:40 -06:00
recurrenceEndDate?: Date;
2016-12-06 08:02:00 -05:00
/**
* Calendar name. Ths is supported by `iOS` only.
*/
2016-02-08 16:11:40 -06:00
calendarName?: string;
2016-12-06 08:02:00 -05:00
/**
* Calendar id
*/
2016-02-08 16:11:40 -06:00
calendarId?: number;
2016-12-06 08:02:00 -05:00
/**
* URL
*/
2016-02-08 16:11:40 -06:00
url?: string;
2016-12-06 08:02:00 -05:00
2016-02-08 16:11:40 -06:00
}
/**
* @name Calendar
* @description
2016-02-08 16:11:40 -06:00
* 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](https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin).
*
2016-08-01 14:01:54 -04:00
*
2016-03-12 18:56:01 -05:00
* @usage
2016-08-01 14:01:54 -04:00
* ```
* import { Calendar } from '@ionic-native/calendar';
2016-08-01 14:01:54 -04:00
*
* constructor(private calendar: Calendar) { }
2016-08-01 14:01:54 -04:00
*
*
* this.calendar.createCalendar('MyCalendar').then(
2016-08-01 14:01:54 -04:00
* (msg) => { console.log(msg); },
* (err) => { console.log(err); }
* );
* ```
* @interfaces
* CalendarOptions
2016-02-08 16:11:40 -06:00
*/
2015-11-30 22:15:21 -06:00
@Plugin({
pluginName: 'Calendar',
2015-11-30 22:15:21 -06:00
plugin: 'cordova-plugin-calendar',
pluginRef: 'plugins.calendar',
2016-03-14 13:38:35 -04:00
repo: 'https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin',
2016-04-29 23:56:49 -04:00
platforms: ['Android', 'iOS']
2015-11-30 22:15:21 -06:00
})
@Injectable()
export class Calendar extends IonicNativePlugin {
/**
* 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
*
2016-10-08 14:54:02 -04:00
* If this returns false, you should call the `requestReadWritePermission` function
* @returns {Promise<boolean>}
*/
@Cordova()
hasReadWritePermission(): Promise<boolean> { return; }
2016-07-08 00:40:35 +02:00
/**
* Check if we have read permission
* @returns {Promise<boolean>}
*/
@Cordova()
hasReadPermission(): Promise<boolean> { return; }
2016-07-08 00:40:35 +02:00
/**
* Check if we have write permission
* @returns {Promise<boolean>}
*/
@Cordova()
hasWritePermission(): Promise<boolean> { return; }
2016-07-08 00:40:35 +02:00
/**
* Request write permission
* @returns {Promise<any>}
*/
@Cordova()
requestWritePermission(): Promise<any> { return; }
2016-07-08 00:40:35 +02:00
/**
* Request read permission
* @returns {Promise<any>}
*/
@Cordova()
requestReadPermission(): Promise<any> { return; }
/**
* Requests read/write permissions
* @returns {Promise<any>}
*/
@Cordova()
requestReadWritePermission(): Promise<any> { return; }
2016-02-08 16:11:40 -06:00
/**
* Create a calendar. (iOS only)
*
2016-08-01 14:01:54 -04:00
* @param {string | Object} nameOrOptions 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
2016-02-08 16:11:40 -06:00
*/
2015-11-30 22:15:21 -06:00
@Cordova()
createCalendar(nameOrOptions: string | any): Promise<any> { return; }
2015-11-30 22:15:21 -06:00
2016-02-08 16:11:40 -06:00
/**
* Delete a calendar. (iOS only)
* @param {string} name Name of the calendar to delete.
* @returns {Promise<any>} Returns a Promise
2016-02-08 16:11:40 -06:00
*/
2015-11-30 22:15:21 -06:00
@Cordova()
deleteCalendar(name: string): Promise<any> { return; }
2015-11-30 22:15:21 -06:00
2016-02-08 16:11:40 -06:00
/**
* Returns the default calendar options.
*
* @return {CalendarOptions} Returns an object with the default calendar options
2016-02-08 16:11:40 -06:00
*/
2016-02-09 14:51:32 -06:00
@Cordova({
sync: true
})
getCalendarOptions(): CalendarOptions { return; }
2015-11-30 22:15:21 -06:00
2016-02-08 16:11:40 -06:00
/**
* Silently create an event.
* @param {string} [title] The event title
* @param {string} [location] The event location
* @param {string} [notes] The event notes
* @param {Date} [startDate] The event start date
* @param {Date} [endDate] The event end date
* @returns {Promise<any>} Returns a Promise
2016-02-08 16:11:40 -06:00
*/
2015-11-30 22:15:21 -06:00
@Cordova()
createEvent(
2016-02-08 16:11:40 -06:00
title?: string,
location?: string,
notes?: string,
startDate?: Date,
endDate?: Date
2016-07-08 00:40:35 +02:00
): Promise<any> { return; }
2015-11-30 22:15:21 -06:00
2016-02-08 16:11:40 -06:00
/**
* Silently create an event with additional options.
*
* @param {string} [title] The event title
* @param {string} [location] The event location
* @param {string} [notes] The event notes
* @param {Date} [startDate] The event start date
* @param {Date} [endDate] The event end date
* @param {CalendarOptions} [options] Additional options, see `getCalendarOptions`
* @returns {Promise<any>} Returns a Promise
2016-02-08 16:11:40 -06:00
*/
2015-11-30 22:15:21 -06:00
@Cordova()
createEventWithOptions(
2016-02-08 16:11:40 -06:00
title?: string,
location?: string,
notes?: string,
startDate?: Date,
endDate?: Date,
options?: CalendarOptions
2016-07-08 00:40:35 +02:00
): Promise<any> { return; }
2015-11-30 22:15:21 -06:00
2016-02-08 16:11:40 -06:00
/**
* Interactively create an event.
*
* @param {string} [title] The event title
* @param {string} [location] The event location
* @param {string} [notes] The event notes
* @param {Date} [startDate] The event start date
* @param {Date} [endDate] The event end date
* @returns {Promise<any>} Returns a Promise
2016-02-08 16:11:40 -06:00
*/
2015-11-30 22:15:21 -06:00
@Cordova()
createEventInteractively(
2016-02-08 16:11:40 -06:00
title?: string,
location?: string,
notes?: string,
startDate?: Date,
endDate?: Date
2016-07-08 00:40:35 +02:00
): Promise<any> { return; }
2015-11-30 22:15:21 -06:00
2016-02-08 16:11:40 -06:00
/**
* Interactively create an event with additional options.
*
* @param {string} [title] The event title
* @param {string} [location] The event location
* @param {string} [notes] The event notes
* @param {Date} [startDate] The event start date
* @param {Date} [endDate] The event end date
* @param {CalendarOptions} [options] Additional options, see `getCalendarOptions`
* @returns {Promise<any>}
2016-02-08 16:11:40 -06:00
*/
2015-11-30 22:15:21 -06:00
@Cordova()
createEventInteractivelyWithOptions(
2016-04-29 23:56:49 -04:00
title?: string,
2016-02-08 16:11:40 -06:00
location?: string,
notes?: string,
startDate?: Date,
endDate?: Date,
options?: CalendarOptions
2016-07-08 00:40:35 +02:00
): Promise<any> { return; }
2015-11-30 22:15:21 -06:00
2016-02-08 16:11:40 -06:00
/**
* Find an event.
*
* @param {string} [title] The event title
* @param {string} [location] The event location
* @param {string} [notes] The event notes
* @param {Date} [startDate] The event start date
* @param {Date} [endDate] The event end date
* @returns {Promise<any>}
2016-02-08 16:11:40 -06:00
*/
2015-11-30 22:15:21 -06:00
@Cordova()
findEvent(
2016-02-08 16:11:40 -06:00
title?: string,
location?: string,
notes?: string,
startDate?: Date,
endDate?: Date
2016-07-08 00:40:35 +02:00
): Promise<any> { return; }
2015-11-30 22:15:21 -06:00
2016-02-08 16:11:40 -06:00
/**
* Find an event with additional options.
* @param {string} [title] The event title
* @param {string} [location] The event location
* @param {string} [notes] The event notes
* @param {Date} [startDate] The event start date
* @param {Date} [endDate] The event end date
* @param {CalendarOptions} [options] Additional options, see `getCalendarOptions`
* @returns {Promise<any>} Returns a Promise that resolves with the event, or rejects with an error.
2016-02-08 16:11:40 -06:00
*/
2015-11-30 22:15:21 -06:00
@Cordova()
findEventWithOptions(
2016-02-08 16:11:40 -06:00
title?: string,
location?: string,
notes?: string,
startDate?: Date,
endDate?: Date,
options?: CalendarOptions
2016-07-08 00:40:35 +02:00
): Promise<any> { return; }
2015-11-30 22:15:21 -06:00
2016-02-08 16:11:40 -06:00
/**
* Find a list of events within the specified date range. (Android only)
*
* @param {Date} [startDate] The start date
* @param {Date} [endDate] The end date
* @returns {Promise<any>} Returns a Promise that resolves with the list of events, or rejects with an error.
2016-02-08 16:11:40 -06:00
*/
@Cordova({
platforms: ['Android']
})
listEventsInRange(startDate: Date, endDate: Date): Promise<any> { return; }
2015-11-30 22:15:21 -06:00
2016-02-08 16:11:40 -06:00
/**
* Get a list of all calendars.
* @returns {Promise<any>} A Promise that resolves with the list of calendars, or rejects with an error.
2016-02-08 16:11:40 -06:00
*/
2015-11-30 22:15:21 -06:00
@Cordova()
listCalendars(): Promise<any> { return; }
2015-11-30 22:15:21 -06:00
2016-02-08 16:11:40 -06:00
/**
* 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.
2016-02-08 16:11:40 -06:00
*/
@Cordova({
platforms: ['iOS']
})
findAllEventsInNamedCalendar(calendarName: string): Promise<any> { return; }
2015-11-30 22:15:21 -06:00
2016-02-08 16:11:40 -06:00
/**
* Modify an event. (iOS only)
*
* @param {string} [title] The event title
* @param {string} [location] The event location
* @param {string} [notes] The event notes
* @param {Date} [startDate] The event start date
* @param {Date} [endDate] The event end date
* @param {string} [newTitle] The new event title
* @param {string} [newLocation] The new event location
* @param {string} [newNotes] The new event notes
* @param {Date} [newStartDate] The new event start date
* @param {Date} [newEndDate] The new event end date
* @return Returns a Promise
*/
@Cordova({
platforms: ['iOS']
})
modifyEvent(
2016-02-08 16:11:40 -06:00
title?: string,
location?: string,
notes?: string,
startDate?: Date,
endDate?: Date,
newTitle?: string,
newLocation?: string,
newNotes?: string,
newStartDate?: Date,
newEndDate?: Date
2016-07-08 00:40:35 +02:00
): Promise<any> { return; }
2015-11-30 22:15:21 -06:00
2016-02-08 16:11:40 -06:00
/**
* Modify an event with additional options. (iOS only)
*
* @param {string} [title] The event title
* @param {string} [location] The event location
* @param {string} [notes] The event notes
* @param {Date} [startDate] The event start date
* @param {Date} [endDate] The event end date
* @param {string} [newTitle] The new event title
* @param {string} [newLocation] The new event location
* @param {string} [newNotes] The new event notes
* @param {Date} [newStartDate] The new event start date
* @param {Date} [newEndDate] The new event end date
* @param {CalendarOptions} [filterOptions] Event Options, see `getCalendarOptions`
* @param {CalendarOptions} [newOptions] New event options, see `getCalendarOptions`
2016-02-08 16:11:40 -06:00
* @return Returns a Promise
*/
@Cordova({
platforms: ['iOS']
})
modifyEventWithOptions(
2016-07-08 00:40:35 +02:00
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> { return; }
2015-11-30 22:15:21 -06:00
2016-07-08 00:40:35 +02:00
/**
* Delete an event.
*
* @param {string} [title] The event title
* @param {string} [location] The event location
* @param {string} [notes] The event notes
* @param {Date} [startDate] The event start date
* @param {Date} [endDate] The event end date
* @return Returns a Promise
*/
2015-11-30 22:15:21 -06:00
@Cordova()
deleteEvent(
2016-02-08 16:11:40 -06:00
title?: string,
location?: string,
notes?: string,
startDate?: Date,
endDate?: Date
2016-07-08 00:40:35 +02:00
): Promise<any> { return; }
2016-02-08 16:11:40 -06:00
/**
* Delete an event from the specified Calendar. (iOS only)
*
* @param {string} [title] The event title
* @param {string} [location] The event location
* @param {string} [notes] The event notes
* @param {Date} [startDate] The event start date
* @param {Date} [endDate] The event end date
* @param {string} calendarName
* @return Returns a Promise
*/
@Cordova({
platforms: ['iOS']
})
deleteEventFromNamedCalendar(
2016-07-08 00:40:35 +02:00
title?: string,
location?: string,
notes?: string,
startDate?: Date,
endDate?: Date,
calendarName?: string
): Promise<any> { return; }
2015-11-30 22:15:21 -06:00
2016-02-08 16:11:40 -06:00
/**
* Open the calendar at the specified date.
2016-08-01 14:01:54 -04:00
* @param {Date} date The date you want to open the calendar on
* @return {Promise<any>} Promise returns a promise
2016-02-08 16:11:40 -06:00
*/
2015-11-30 22:15:21 -06:00
@Cordova()
openCalendar(date: Date): Promise<any> { return; }
2016-07-20 17:17:09 +02:00
2015-11-30 22:15:21 -06:00
}