What is the EventKit method of loading calendars to synchronize calendar events on a local unit to a server? In applescript,
tell application "Calendar" to reload calendars
appears to refresh the local calendar or synchronize the local calendar with a server calendar.
Although I assumed that the EventKit equivalent would be to load the Event Calendars, I cannot find such EventKit function.I found an Eventkit refreshSourcesIfNecessary function, but my applescript implementation failed.
use framework "Foundation"
use framework "EventKit"
# create event storage or database
set theEKEventStore to current application's EKEventStore's alloc()'s init()
# request access for theEKEventStore to assemble a database of Calendars
theEKEventStore's requestAccessToEntityType:0 completion:(missing value)
# my failed attempt to refresh sources of events to sync events with server
theEKEventStore's refreshSourcesIfNecessary()
Perplexed.
Please let me know of any EventKit solution for event synchronization that has worked for you.
I wrote the above script to be triggered by a user after a user created a new calendar event with the Calendar app menu commands. I was under the impression that an applescript command to reload calendars then allowed EventKit to identify a new event. In my original script, EventKit did not recognize a new event, absent Calendar app’s applescript command to reload calendars.
In regard to your suggestion, my attempt at the following script
set the theEKEventStoreReset to theEKEventStore's reset()
yielded no apparent result, in the context I was describing.
The problem, I suspect, is that you’re at the mercy of Calendar.app and when it is going to commit any changes. Reloading is aimed at the calendar store, not any other clients who may also be accessing it.
How do I have EventKit or Calendar app commit an event, if I have an event that a user has created via the Calendar app’s user interface, but that apparently has not been committed?
The following EK Event Store’s function to save an event by committing it, requires an event that has already been committed.
set {theResult, theError} to theEKEventStore's saveEvent:theEvent span:true commit:true |error|:(reference)
Any ideas on how to proceed on committing an uncommitted event?