1

在我的应用程序中,我使用EventKitAPI 访问设备上的日历,并将它们显示在我的视图中。但是,在使用网络日历时,我怀疑它EKEventStore只会在查询时返回某种缓存/本地事件列表,而不是重新加载日历并返回实际/最新内容。
当启动本机日历应用程序时,应用程序将刷新/重新加载所有日历,同步任何网络共享日历。现在回到我的应用程序也将显示新同步的事件。

除此之外,我发现通过我的应用程序修改任何事件(删除/更新)并且EventKit / EventKitUI不会同步回例如我的 Mac 的日历。

长话短说:有没有办法强制与EventKit/iOS SDK 中的网络共享日历同步?

4

1 回答 1

10
  1. You can use the - (void)refreshSourcesIfNecessary method of an EKEventStore instance to:

    ... pull new data from remote sources if the local data is out of date.

    This would force an update of the local calendar store by fetching the latest remote data. I have a feeling this is the method the native iOS Calendar app is using to prompt an update.

  2. As for the issue with deleted and updated calendar events not syncing to your Mac, are you sure you are calling - (void)commit: on your EKEventStore instance after you have made your modifications?

    Alternatively, there is a selection of methods within EKEventStore for saving and remove calendars and events that also offer a commit parameter which can immediately commit your changes. I would post the links but as a new user I can only use two hyperlinks.

    - (void)saveEvent:span:commit:error:
    - (void)removeEvent:span:commit:error:

    Assuming these events are being added to a cloud based calendar, this should have the effect of synchronising your changes to your Mac.

于 2013-01-26T13:02:54.180 回答