TechnologiesCommunication, Contacts & Messaging

ContactProvider

iOSmacOStvOSwatchOSvisionOS

ContactProvider lets you build an app extension that supplies contact items from a custom contact database on iOS. You conform to ContactProviderExtension and define a ContactProviderDomain, enumerate items through ContactItemEnumerating and ContactItemEnumerator returning a ContactItemPage, and track changes against a ContactItemSyncAnchor. To surface updates, you implement ContactItemChangeObserver and ContactItemContentObserver, while ContactProviderManager coordinates the extension and ContactProviderError reports failures.

Essentials 3

Conform to the extension and domain protocols that anchor a custom contact provider.

  • Pr
    ContactProviderExtension
    The extension `@main` class implements this protocol.
  • Pr
    ContactProviderDomain
    A domain, including traits like an identifier and display name, used to configure the extension.
  • St
    DefaultContactProviderDomain
    The default domain the extension uses.

Coordinating the Extension 1

Use the manager to register and coordinate your contact provider extension with the system.

  • Cl
    ContactProviderManager
    An interface for the app to control its extension.

Enumerating Contact Items 4

Enumerate contact items from your custom database in paged batches.

  • Pr
    ContactItemEnumerating
    A protocol to provide enumerators for collections of contact items.
  • Pr
    ContactItemEnumerator
    A protocol to provide enumerations of all contact items and changed contact items.
  • St
    ContactItemPage
    A fixed offset into enumerating all contact items.
  • En
    ContactItem
    An item in the contact database.

Tracking and Observing Changes 3

Track sync state and observe content and change updates to keep contacts current.

  • St
    ContactItemSyncAnchor
    A snapshot point into enumerating changed contact items.
  • Pr
    ContactItemChangeObserver
    A protocol that defines a system observer that receives a resumable enumeration of changed contact items.
  • Pr
    ContactItemContentObserver
    A protocol that defines a system observer that receives a resumable enumeration of all items.

Errors 1

Handle failures reported by the contact provider.

  • En
    ContactProviderError
    Errors thrown by the Contact Provider framework.
← Communication, Contacts & Messaging