如何接受/拒绝EKEvent邀请? [英] How to accept/decline EKEvent invitation?

查看:124
本文介绍了如何接受/拒绝EKEvent邀请?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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


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


在这个



我错过了什么,或者这是不可能的?如果无法保存任何内容,为什么他们会允许与这些按钮互动?



谢谢!



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




  • 隐私 - 日历使用说明

  • 隐私 - 联系方式使用说明

  • 隐私 - 提醒使用说明



更新:



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



解决方案

要允许用户创建,编辑或删除事件,请使用 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:
...
}

}


I would like to allow my users to accept/decline a meeting invitation within my app.

I think what I need is to update somehow the EKParticipantStatus but it looks like it isn't possible to update.

Apple Docs: Event Kit cannot add participants to an event nor change participant information

In this stackOverflow question someone suggested to bring the native EventKitUI, which I've tried like this:

  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)
        }

The native UI shows pretty good but the buttons don't make any effect in the native calendar.

Am I missing something or it's just not possible? Why would they allow to interact with those buttons if it's not possible to save anything?

Thank you!

PD: I have these permissions in the info.plist:

  • Privacy - Calendars Usage Description
  • Privacy - Contacts Usage Description
  • Privacy - Reminders Usage Description

UPDATE:

Please note that EKEventEditViewController is not what I am looking for. This screen wouldn't allow me to accept or decline the event, it would only allow me to edit the details.

解决方案

To allow the user to create, edit, or delete events, use the 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 class must conform to the EKEventEditViewDelegate protocol and must implement the eventEditViewController method to dismiss the modal view controller as shown below:

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

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

}

这篇关于如何接受/拒绝EKEvent邀请?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆