CalendarEvent
The CalendarEvent API enables creating, reading, editing, and managing events in the iOS calendar.
Developers can configure event details such as title, time, location, participants, recurrence rules, alarms, availability, and structured locations, and can display system-provided interfaces for creating or editing events.
1. Types
EventParticipant
Represents an attendee of the event:
isCurrentUser: boolean– Indicates whether this attendee represents the current username?: string– Display namerole: ParticipantRole– The attendee’s roletype: ParticipantType– The type of attendeestatus: ParticipantStatus– The attendee’s participation status
ParticipantRole
chairnonParticipantoptionalrequiredunknown
ParticipantType
grouppersonresourceroomunknown
ParticipantStatus
unknownpendingaccepteddeclinedtentativedelegatedcompletedinProcess
EventAvailability
Indicates how the event affects the user’s availability:
notSupportedbusyfreetentativeunavailable
EventStructuredLocation
Describes a location that can be used for location-based alarms.
title: string | null– A name for the locationgeoLocation: LocationInfo | null– Latitude and longituderadius: number– Radius in meters for the geofence trigger
AlarmProximity
Describes how a location alarm triggers:
noneenterleave
2. EventAlarm
CalendarEvent supports attaching one or more EventAlarm instances.
Alarms may be:
- absolute date alarms
- relative alarms (relative to the start of the event)
- location-based alarms using geofence triggers
See the EventAlarm documentation for detailed information.
3. CalendarEvent Class
Constructor
Creates an in-memory event instance.
Call save() to persist it into the calendar.
4. Properties
General Information
identifier: string
A unique identifier for the event.
title: string
The title of the event.
notes: string | null
Additional notes.
url: string | null
A URL associated with the event.
calendar: Calendar | null
The calendar to which the event belongs.
This property cannot be set to null. To remove an event, use remove().
Time and Location
isAllDay: boolean
Indicates whether the event lasts all day.
startDate: Date
The start date and time.
endDate: Date
The end date and time.
timeZone: string | null
The event’s time zone.
location: string | null
A text description of the location.
structuredLocation: EventStructuredLocation | null
A structured location that includes geolocation data for alarms.
Event Metadata
creationDate: Date | null
The date when the event was created.
lastModifiedDate: Date | null
The date of the most recent modification.
occurrenceDate: Date
For recurring events, this is the original scheduled date of this specific occurrence.
isDetached: boolean
Indicates whether this event represents a modified occurrence of a recurring series.
Participants and Availability
attendees: EventParticipant[] | null
An array of attendees.
organizer: EventParticipant | null
The organizer of the event.
hasAttendees: boolean
Indicates whether the event has attendees.
availability: EventAvailability
Indicates the event’s impact on availability.
Alarms
alarms: EventAlarm[] | null
The alarms associated with the event.
hasAlarm: boolean
Indicates whether the event has any alarms.
Recurrence
recurrenceRules: RecurrenceRule[] | null
The recurrence rules of the event.
hasRecurrenceRules: boolean
Indicates whether the event has recurrence rules.
Additional State Flags
hasNotes: boolean
Indicates whether the event contains notes.
hasChanges: boolean
Indicates whether the event or any nested objects contain unsaved changes.
5. Instance Methods
Alarm Management
addAlarm(alarm: EventAlarm): void
Adds an alarm to the event.
removAlarm(alarm: EventAlarm): void
Removes an alarm from the event.
(Note: The method name is removAlarm.)
Recurrence Management
addRecurrenceRule(rule: RecurrenceRule): void
Appends a recurrence rule.
removeRecurrenceRule(rule: RecurrenceRule): void
Removes a recurrence rule.
Saving and Deleting
save(): Promise<void>
Saves the event to the calendar.
remove(): Promise<void>
Removes the event from the calendar.
Editing UI
presentEditView(): Promise<EventEditViewAction>
Displays the system event-editing interface and resolves with:
saveddeletedcanceled
6. Static Methods
CalendarEvent.getAll(startDate: Date, endDate: Date, calendars?: Calendar[]): Promise<CalendarEvent[]>
Fetches calendar events within a given date range.
- Provide an array of calendars to restrict the search
- Use
nullor omit the parameter to search all calendars
CalendarEvent.presentCreateView(): Promise<CalendarEvent | null>
Displays the system interface for creating a new event.
- Returns the created event if saved
- Returns
nullif canceled
7. Usage Examples
Creating and Saving an Event
Adding a Recurrence Rule
Adding an Alarm
Fetching Events
Presenting the Create View
Editing an Existing Event
Removing an Event
8. Additional Notes
Time Zone Considerations
When working with events that span time zones, set timeZone explicitly to avoid incorrect scheduling or display.
Recurring Events
Editing individual occurrences of a recurring event may produce a detached instance.
Use occurrenceDate to determine the original date of the modified occurrence.
Attendees
Attendee data depends on the calendar source (iCloud, Exchange, etc.) and may vary in availability.
Structured Location
When using location-based alarms, the user must grant the necessary location permissions.
