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
EventParser
protocol.Declaration
Swift
public var eventsParser: E
-
Reminders parser, an instance of the
ReminderParser
protocol.Declaration
Swift
public var remindersParser: R
-
EventKit interface, an instance of the
EventKitInterfaceProtocol
protocol.Declaration
Swift
public let eventKitInterface: EventKitInterfaceProtocol
-
Supported keys.
Declaration
Swift
public let keys: [AutoMateLaunchOptionKey]
-
Initialize this handler with parsers.
eventsParser
transformsDictionary
toEKEvent
,remindersParser
transformsDictionary
toEKReminder
and interface which is responsible for interacting withEventKit
.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 transformingDictionary
toEKEvent
.remindersParser
Reminders parser, an instance of type that conforms to the
ReminderParser
protocol. Responsible for transformingDictionary
toEKReminder
.eventKitInterface
EventKit interface, an instance of type that conforms to the
EventKitInterfaceProtocol
protocol. responsible for interacting withEventKit
.
-
Handles value for the
AM_EVENTS_KEY
and theAM_REMINDERS_KEY
keys and manage events and reminders.Declaration
Swift
public func handle(key: String, value: String)
Parameters
key
AM_EVENTS_KEY
,AM_REMINDERS_KEY
/AutoMateLaunchOptionKey.events
,AutoMateLaunchOptionKey.reminders
.value
LaunchEnvironmentResource
resources representation as a string.