我想让我的用户在我的应用程序中接受/拒绝 session 邀请。
我认为我需要以某种方式更新 EKParticipantStatus,但看起来无法更新。
Apple Docs: Event Kit cannot add participants to an event nor change participant information
在此stackOverflow question有人建议带上原生的 EventKitUI,我试过这样:
class CalendarViewController: UIViewController, EKEventViewDelegate {
// .....
let eventController = EKEventViewController()
guard let eventWithIdentifier = MeetingsFetcher.eventStoreClass.event(withIdentifier: meeting.UUID) else {
return nil
}
eventController.delegate = self
eventController.event = eventWithIdentifier
eventController.allowsEditing = true
eventController.allowsCalendarPreview = true
let navCon = UINavigationController(rootViewController: eventController)
// customizing the toolbar where the accept/maybe/decline buttons appear
navCon.toolbar.isTranslucent = false
navCon.toolbar.tintColor = .blueGreen
navCon.toolbar.backgroundColor = .coolWhite10
// customizing the nav bar where the OK button appears
navCon.navigationBar.callinAppearence()
present(navCon, animated: true, completion: nil)
// .....
// view gets dismissed, so it does detects the action, but no effect
func eventViewController(_ controller: EKEventViewController, didCompleteWith action: EKEventViewAction) {
controller.dismiss(animated: true, completion: nil)
}
native UI 显示效果很好,但按钮在 native 日历中没有任何效果。
我是不是遗漏了什么或者这不可能?如果无法保存任何内容,他们为什么允许与这些按钮进行交互?
谢谢!
PD:我在 info.plist 中有这些权限:
- 隐私 - 日历使用说明
- 隐私 - 联系人使用说明
- 隐私 - 提醒使用说明
更新:
请注意,EKEventEditViewController 不是我要找的。此屏幕不允许我接受或拒绝事件,它只允许我编辑详细信息。
最佳答案
要允许用户创建、编辑或删除事件,请使用 EKEventEditViewDelegate
协议(protocol)。
let eventController = EKEventViewController()
guard let eventWithIdentifier = MeetingsFetcher.eventStoreClass.event(withIdentifier: meeting.UUID) else {
return nil
}
eventController.delegate = self
eventController.event = eventWithIdentifier
eventController.editViewDelegate = self
...
CalendarViewController
类必须符合 EKEventEditViewDelegate
协议(protocol),并且必须实现 eventEditViewController
方法来关闭模态视图 Controller ,如下所示:
func eventEditViewController(_ controller: EKEventEditViewController,
didCompleteWith action: EKEventEditViewAction) {
switch (action) {
case EKEventEditViewActionCanceled:
case EKEventEditViewActionSaved:
...
}
}
关于ios - 如何接受/拒绝 EKEvent 邀请?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48170415/