【问题标题】:How to accept/decline EKEvent invitation?如何接受/拒绝 EKEvent 邀请?
【发布时间】:2018-06-18 14:52:04
【问题描述】:

我想允许我的用户在我的应用中接受/拒绝会议邀请。

我认为我需要以某种方式更新 EKParticipantStatus,但看起来无法更新。

Apple Docs:Event Kit 无法将参与者添加到事件中,也无法更改参与者 信息

在这个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)
        }

原生 UI 显示效果不错,但按钮在原生日历中没有任何效果。

是我遗漏了什么还是不可能?如果无法保存任何内容,他们为什么允许与这些按钮进行交互?

谢谢!

PD:我在 info.plist 中有这些权限:

  • 隐私 - 日历使用说明
  • 隐私 - 联系人使用说明
  • 隐私 - 提醒使用说明

更新:

请注意,EKEventEditViewController 不是我想要的。此屏幕不允许我接受或拒绝该事件,它只允许我编辑详细信息。

【问题讨论】:

  • 曾经找到答案吗?试图解决同样的问题。

标签: ios swift ekevent ekeventstore ekeventkit


【解决方案1】:

要允许用户创建、编辑或删除事件,请使用EKEventEditViewDelegate 协议。

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 协议,并且必须实现eventEditViewController 方法来关闭模态视图控制器,如下所示:

func eventEditViewController(_ controller: EKEventEditViewController, 
             didCompleteWith action: EKEventEditViewAction) {

    switch (action) {
        case EKEventEditViewActionCanceled:
        case EKEventEditViewActionSaved:
        ...
    }

}

【讨论】:

  • 谢谢,但这不是我要找的。这不允许拒绝或接受邀请。 Canceled 表示用户取消了对事件所做的更改。这并不意味着用户拒绝了它。我将用屏幕截图更新我的答案,以便您了解我的意思。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-01-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-06-06
  • 1970-01-01
  • 2014-08-19
相关资源
最近更新 更多