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
ContactParserprotocol.Declaration
Swift
public let contactParser: C -
Contact interface, an instance of the
ContactsInterfaceprotocol.Declaration
Swift
public let contactsInterface: I
-
Initialize this handler with parser (which transform
DictionarytoCNMutableContact) and interface (which is responsible for interacting withContactsframework).Declaration
Swift
public init(withParser contactParser: C, contactsInterface: I)Parameters
contactParserContact parser, an instance of type that conforms to the
ContactParserprotocol. Responsible for transforingDictionarytoCNMutableContact.contactsInterfaceContact interface, an instance of type that conforms to the
ContactsInterfaceprotocol. Responsible for interacting withContactsframework
-
Handles value for the
AM_CONTACTS_KEYkey and manage contacts.Declaration
Swift
public func handle(key: String, value: String)Parameters
keyAM_CONTACTS_KEY/AutoMateLaunchOptionKey.contacts.valueLaunchEnvironmentResourceresources representation as a string.
ContactsHandler Structure Reference