Contents

ContactProviderManager

An interface for the app to control its extension.

Declaration

class ContactProviderManager

Overview

Use this class to initially enable your contact provider app extension, making it visible to the system and other apps. To use the default domain, create a manager and call enable(). This is an async call, because it may prompt the person using your app to approve turning on the contact provider.

import ContactProvider

func enableExtensionExample() async {
    do {
        // The app creates a contact provider manager with a default domain.
        let manager = try ContactProviderManager()
        
        // May prompt the person to enable the default domain.
        try await manager.enable()
    } catch {
        // Handle the error.
    }
}

Signaling the app extension

You also use ContactProviderManager when you need to invoke the app extension on demand. For example, when your app knows new contacts are available from your server, call signalEnumerator(for:) so the extension can fetch and provide the changed contacts.

import ContactProvider

func refreshForNewContacts() async {
    do {
        let manager = try ContactProviderManager()
        try await manager.signalEnumerator()
    } catch {
        // Handle the error.
    }
}

Topics

Creating a contact provider manager

Invoking the app extension

Managing the contact provider manager life cycle

Managing the domain