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.

  • Initialize this handler with parser (which transform Dictionary to CNMutableContact) and interface (which is responsible for interacting with Contacts 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 transforing Dictionary to CNMutableContact.

    contactsInterface

    Contact interface, an instance of type that conforms to the ContactsInterface protocol. Responsible for interacting with Contacts framework