ContactsHandler
public struct ContactsHandler<C, I> : Handler where C : ContactParser, I : ContactsInterface
Handles contacts by using Contacts
framework.
Handler should be added to LaunchEnvironmentManager
.
Used key: AM_CONTACTS_KEY
/ AutoMateLaunchOptionKey.contacts
.
Supported values: LaunchEnvironmentResource
resources representation as a string.
Example:
let launchManager = LaunchEnvironmentManager()
let contactsHander = ContactsHandler(withParser: ContactDictionaryParser(with: CNContactStore()), contactsInterface: ContactsInterface())
launchManager.add(handler: contactsHander, for: .contacts)
launchManager.setup()
Note
defaultContactsHander
singleton could be used intead of creating new instance of the ContactsHandler
.
Note
Launch environment for the handler can be set by the ContactLaunchEnvironment
from the AutoMate project.
Note
ContactsHandler
should be used with the AM_CONTACTS_KEY
key, but its implementation doesn’t require to use it.
Any key provided to the LaunchEnvironmentManager.add(handler:for:)
method will be handled correctly.
Seealso
Seealso
Seealso
-
Contact parser, an instance of the
ContactParser
protocol.Declaration
Swift
public let contactParser: C
-
Contact interface, an instance of the
ContactsInterface
protocol.Declaration
Swift
public let contactsInterface: I
-
Initialize this handler with parser (which transform
Dictionary
toCNMutableContact
) and interface (which is responsible for interacting withContacts
framework).Declaration
Swift
public init(withParser contactParser: C, contactsInterface: I)
Parameters
contactParser
Contact parser, an instance of type that conforms to the
ContactParser
protocol. Responsible for transforingDictionary
toCNMutableContact
.contactsInterface
Contact interface, an instance of type that conforms to the
ContactsInterface
protocol. Responsible for interacting withContacts
framework
-
Handles value for the
AM_CONTACTS_KEY
key and manage contacts.Declaration
Swift
public func handle(key: String, value: String)
Parameters
key
AM_CONTACTS_KEY
/AutoMateLaunchOptionKey.contacts
.value
LaunchEnvironmentResource
resources representation as a string.