EventKitHandler

public class EventKitHandler<E: EventParser, R: ReminderParser, I: EventKitInterfaceProtocol>: Handler
    where E.T == [String: Any],
        R.T == [String: Any]

Handles events and reminders by using EventKit framework.

Handler should be added to LaunchEnvironmentManager.

Used key: AM_EVENTS_KEY, AM_REMINDERS_KEY / AutoMateLaunchOptionKey.events, AutoMateLaunchOptionKey.reminders.

Supported values: LaunchEnvironmentResource resources representation as a string.

Example:

let launchManager = LaunchEnvironmentManager()
let eventsHander = EventKitHandler(withParsers: EventDictionaryParser(with: EKEventStore()), ReminderDictionaryParser(with: EKEventStore()),
                                   eventKitInterface: EventKitInterface())
launchManager.add(handler: eventsHander, for: .events)
launchManager.add(handler: eventsHander, for: .reminders)
launchManager.setup()

Note

defaultEventKitHander singleton could be used intead of creating new instance of the EventKitHandler.

Note

Launch environment for the handler can be set by the EventLaunchEnvironment and ReminderLaunchEnvironment from the AutoMate project.

Warning

EventKitHandler is working only with the AM_EVENTS_KEY and AM_REMINDERS_KEY key. If any other key will be used handler will throw an exception.

  • Initialize this handler with parsers. eventsParser transforms Dictionary to EKEvent, remindersParser transforms Dictionary to EKReminder and interface which is responsible for interacting with EventKit.

    Declaration

    Swift

    public init(withParsers eventsParser: E, _ remindersParser: R, eventKitInterface: I)

    Parameters

    eventsParser

    Events parser, an instance of type that conforms to the EventParser protocol. Responsible for transforming Dictionary to EKEvent.

    remindersParser

    Reminders parser, an instance of type that conforms to the ReminderParser protocol. Responsible for transforming Dictionary to EKReminder.

    eventKitInterface

    EventKit interface, an instance of type that conforms to the EventKitInterfaceProtocol protocol. responsible for interacting with EventKit.