IS2Calendar Class Reference

Inherits from NSObject
Declared in IS2Calendar.h

Overview

IS2Calendar is used to create, read, and modify events stored in the user’s calendar; all changes will be reflected immediately in Calendar.app. For those using this API in JavaScript, all timestamps utilised are in milliseconds, to allow interoperability with Date objects.

Please note that this class is not yet complete; more methods relating to modifying events will need to be added.

Setup

+ registerForCalendarNotificationsWithIdentifier:andCallback:

Sets a block to be called whenever the user’s calendar changes, such as when the Calendar app adds or modifies an event. The identifier must be unique string; it is recommended to use reverse DNS notation, such as “com.foo.bar”.

+ (void)registerForCalendarNotificationsWithIdentifier:(NSString *)identifier andCallback:(void ( ^ ) ( void ))callbackBlock

Parameters

identifier

The identifier associated with your callback

callbackBlock

The block to call once data changes

Declared In

IS2Calendar.h

+ unregisterForNotificationsWithIdentifier:

The inverse of registering for notifications. This must be called when your code is unloaded!

+ (void)unregisterForNotificationsWithIdentifier:(NSString *)identifier

Parameters

identifier

The identifier associated with your callback

Declared In

IS2Calendar.h

Creating new events

+ addCalendarEntryWithTitle:location:startTimeAsTimestamp:andEndTimeAsTimestamp:isAllDayEvent:

Adds a new calendar entry to the device. This method is for usage by JavaScript developers; the timestamp is assumed to be in terms of milliseconds, such as that provided by Date.now().

+ (void)addCalendarEntryWithTitle:(NSString *)title location:(NSString *)location startTimeAsTimestamp:(time_t)startTime andEndTimeAsTimestamp:(time_t)endTime isAllDayEvent:(BOOL)isAllDay

Parameters

title

Title of the new calendar event.

location

Location of the event - this can be null.

startTime

Start time of the event, as a timestamp in milliseconds

endTime

End time of the event, again as a timestamp in milliseconds

isAllDay

Defines whether the new event is to last all day - ensure that startTime is 00:00 of the day specified

Declared In

IS2Calendar.h

+ addCalendarEntryWithTitle:location:startTime:andEndTime:isAllDayEvent:

Adds a new calendar entry to the device; this is intended for usage via Objective-C.

+ (void)addCalendarEntryWithTitle:(NSString *)title location:(NSString *)location startTime:(NSDate *)startTime andEndTime:(NSDate *)endTime isAllDayEvent:(BOOL)isAllDay

Parameters

title

Title of the new calendar event.

location

Location of the event - this can be null.

startTime

Start time of the event

endTime

End time of the event

isAllDay

Defines whether the new event is to last all day - ensure that startTime is 00:00 of the day specified

Declared In

IS2Calendar.h

+ addCalendarEntryWithTitle:andLocation:

Adds a new calendar entry to the device. The start time of the event is assumed to be the time at which the method is called, and the end time is an hour afterwards.

+ (void)addCalendarEntryWithTitle:(NSString *)title andLocation:(NSString *)location

Parameters

title

Title of the new calendar event.

location

Location of the event - this can be null.

Declared In

IS2Calendar.h

Retrieving events

+ calendarEntriesJSONBetweenStartTimeAsTimestamp:andEndTimeAsTimestamp:

A JSON array representing calendar events between the two timestamps specified. This is sourced from all available calendars defined by the user.

+ (NSString *)calendarEntriesJSONBetweenStartTimeAsTimestamp:(time_t)startTime andEndTimeAsTimestamp:(time_t)endTime

Parameters

startTime

Start time of the event, as a timestamp in milliseconds

endTime

End time of the event, again as a timestamp in milliseconds

Return Value

JSON representation of the requested calendar events, in the form:
[
 {
  “title”: “Example event”,
  “location”: “Example location”,
  “allDay”: 0, (Boolean defining whether the current event is to run all day)
  “startTimeTimestamp”: 1451528264000, (Timestamp in milliseconds)
  “endTimeTimestamp”: 1451692799000, (Timestamp in milliseconds)
  “associatedCalendarName”: “Default”,
  “associatedCalendarHexColor”: “#C6F4D2”
 },
 {
  …
 }
]

Declared In

IS2Calendar.h

+ calendarEntriesBetweenStartTime:andEndTime:

Gives an array of calendar events between the dates specified. This is sourced from all available calendars defined by the user.

+ (NSArray *)calendarEntriesBetweenStartTime:(NSDate *)startTime andEndTime:(NSDate *)endTime

Parameters

startTime

Start time of the event

endTime

End time of the event

Return Value

An array of EKEvent objects representing calendar entries

Declared In

IS2Calendar.h