I'm creating an app in Swift that shows the user events with dates that are sent from a server. These events have unique identifiers. One of the features of the app allows the user to schedule these events, saving them in the iOS Calendar. The problem is the app needs to show the users which events have been scheduled in the iOS Calendar. To do this I can compare titles and dates from the events in my app with the events the user saved in the Calendar, but there might be two events with the same dates and titles. So I need to store the event's unique custom identifier inside the iOS Calendar item. EKCalendarItem seems to have no variable I can use. If I save it in notes, the user could change the identifier. Any ideas how to solve this problem? I'm using the EventKit framework.
As far as I know, you can't store your own IDs in calendar entries. I would recommend that you store the external IDs of the entries together with the ID of the iOS calendar entry in a local data structure.
Possibly a dictionary with the external ID as key and the EKEvent.eventIdentifier
as value.
In addition you should listen to changes in the calendar to be able to react if necessary. (EKEventStoreChangedNotification
)