ContactsInterface

public class ContactsInterface : ContactsInterfaceProtocol

Provides a basic mechanism for interacting with the Contacts framework.

Conforms to the ContactsInterfaceProtocol protocol.

Seealso

ContactsHandler
  • Initialize object with the CNContactStore and a fetch request.

    If the contact store is not provided a new one is created. The fetch request is used for contacts removal. If not provided, the default fetch request will be used which will match to all contacts on a device.

    Declaration

    Swift

    public init(contactStore: CNContactStore = CNContactStore(), fetchRequest: CNContactFetchRequest? = nil)

    Parameters

    contactStore

    A contact store used to communicate.

    fetchRequest

    A fetch request used for contacts removal.

  • Adds all contacts to the CNContactStore.

    Declaration

    Swift

    public func addAll(_ contacts: [CNMutableContact], completion: @escaping ContactsInterfaceProtocol.CompletionBlock)

    Parameters

    contacts

    List of contacts.

    completion

    Completion closure called after contacts were saved to the store.

  • Remove all contacts from the CNContactStore.

    Declaration

    Swift

    public func removeAll(completion: @escaping ContactsInterfaceProtocol.CompletionBlock)

    Parameters

    completion

    Completion closure called after contacts were removed from the store.

  • Request access to the Contacts framework.

    Declaration

    Swift

    public func requestAccess(completion: @escaping ContactsInterfaceProtocol.CompletionBlock)

    Parameters

    completion

    Completion closure.