What exactly constitutes a "full calendar sync" in EKCalendar?

calendar, eventkit, ios, objective-c

Solution

When exactly does a "full sync" occur? Calendar and Reminders Programming Guide explains this questions in this way:

If a change to the Calendar database occurs from outside of your app, Event Kit is able to detect the change by notification so your app can act appropriately. Changes made to calendar items with Event Kit are automatically synced to the associated calendar (CalDAV, Exchange, and so on).

I see such scenarios of "full sync" events while your app is open: 1. User sends your app to background and opens Calendar app. He changes calendar name, adds/edits/deletes events or even removes some calendar. 2. User applies some changes to iCloud calendar on Mac. iOS device is notified that iCloud calendar was changed so it has to be synchronized. 3. Third-party app receives silent notification, iOS launches it in background, app creates some calendar event based on notification.

In general it means that "full sync" event can happen at any time.

How to detect and handle "full sync" event? Observing External Changes to the Calendar Database explains this questions in this way:

It’s possible for another process or app to modify the Calendar database while your app is running. If your app fetches calendar events or reminders, you should register to be notified about changes to the Calendar database. By doing so, you ensure that the calendar and reminder information you display to the user is current.

Here is code sample for registering to such notification:

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(storeChanged:)
                                             name:EKEventStoreChangedNotification
                                           object:eventStore];

I think it makes sense to recreate instances of `EKCalendar` classes and recache `calendarIdentifier` if needed.

What properties are liable to change besides the calendarIdentifier? I can't find any documentation about this question. But since calendar can even doesn't exist at some moment (for example user manually removes it in Calendar app) then any property of `EKCalendar` object can be invalid after "full sync" event happens.

Also it makes sense to read above links for more information and details.

Problem

The documentation for the `EKCalendar` class states this for the `calendarIdentifier` property: A full sync with the calendar will lose this identifier. You should have a plan for dealing with a calendar whose identifier is no longer fetch-able by caching its other properties. When exactly does a "full sync" occur and what properties are liable to change besides the `calendarIdentifier`?

Original source

Related problems