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.
Seealso
Seealso
Seealso
-
Events parser, an instance of the
EventParserprotocol.Declaration
Swift
public var eventsParser: E -
Reminders parser, an instance of the
ReminderParserprotocol.Declaration
Swift
public var remindersParser: R -
EventKit interface, an instance of the
EventKitInterfaceProtocolprotocol.Declaration
Swift
public let eventKitInterface: EventKitInterfaceProtocol -
Supported keys.
Declaration
Swift
public let keys: [AutoMateLaunchOptionKey]
-
Initialize this handler with parsers.
eventsParsertransformsDictionarytoEKEvent,remindersParsertransformsDictionarytoEKReminderand interface which is responsible for interacting withEventKit.Declaration
Swift
public init(withParsers eventsParser: E, _ remindersParser: R, eventKitInterface: I)Parameters
eventsParserEvents parser, an instance of type that conforms to the
EventParserprotocol. Responsible for transformingDictionarytoEKEvent.remindersParserReminders parser, an instance of type that conforms to the
ReminderParserprotocol. Responsible for transformingDictionarytoEKReminder.eventKitInterfaceEventKit interface, an instance of type that conforms to the
EventKitInterfaceProtocolprotocol. responsible for interacting withEventKit.
-
Handles value for the
AM_EVENTS_KEYand theAM_REMINDERS_KEYkeys and manage events and reminders.Declaration
Swift
public func handle(key: String, value: String)Parameters
keyAM_EVENTS_KEY,AM_REMINDERS_KEY/AutoMateLaunchOptionKey.events,AutoMateLaunchOptionKey.reminders.valueLaunchEnvironmentResourceresources representation as a string.
EventKitHandler Class Reference