Difference between EKEvent eventIdentifier and calendarItemExternalIdentifier

Reading Apple docs, I'm still confused as to what the difference is between the EKCalenderItem calendarItemExternalIdentifier and the EKEvent eventIdentifier , and which one should we use to identify calendar events on different devices. In particular:

EKCalendarItem calendarItemExternalIdentifier The external calendar identifier provided by the calendar server. (Only for reading)

and

EKEvent eventIdentifier: A unique identifier for the event. (Only for reading)

The EKCalendarItem calendarItemExternalIdentifier was added in iOS6, and I would think that it would be an identifier that I need to save in order to call later in the EKEventStore eventWithIdenfier: as it states:

This identifier allows you to access the same event or reminder across multiple devices.

But in my own testing, it seems that when I create and save a new EKEvent, the eventIdenifier that I get from the EKEvent object is unique and useful, and the resulting CalendarItemExternalIdentifier does not seem to work with the EKEventStore eventWithIdenfier:

If anyone has a definitive answer, I would love to know.

+7
ios objective-c ekeventstore eventkit ekevent
source share
2 answers

calendarItemExternalIdentifier is an RFC 5545 globally unique identifier. It is not specific to EKEventStore, and indeed represents this event on all devices (as well as through non-iOS clients). If you want to open the .ics application from your mailbox, this value will be displayed in the UID field of the invitation.

However, you cannot directly search for EKEventStore events based on this identifier. Instead, you need to search for predicates in the event store and check the calendarItemExternalIdentifier on each event.

+6
source share

calendarItemExternalIdentifier can be found using

 func calendarItemsWithExternalIdentifier(externalIdentifier: String) -> [EKCalendarItem] 

Although accessibility is noted by iOS 6.0, until recently, this may be undocumented (even a private api). Interestingly, you can get multiple items back, so it should be possible to get all instances of a recurring event (not yet verified)

The calendarItemExternalIdentifier documentation is also updated, just for completeness, here it is:

This identifier allows you to access a single event or reminder on multiple devices. There are times when duplicate calendar instances can exist in the same database:

Calendar item was imported from ICS file to multiple calendars

The event was created on a calendar shared with the user and the user was also invited to the event

The user is a calendar delegate who also has this event.

A custom calendar has been added to multiple accounts.

In such cases, you should choose between calendar items based on other factors, such as a calendar or source.

Duplicate event identifiers are the same for all occurrences. if you want to distinguish between cases, you can use the start date.

For Exchange servers, the identifier is different from iOS and OS X and different between reminder devices.

+3
source share

All Articles