QNAddressBooksRepository
public actor QNAddressBooksRepository
Service to manage contact actions and subscribe to contact events
-
Sources from which the contacts will be fetched
- contacts
- phonebooks
- domain
- static
- groups
Declaration
Swift
public enum Source : String
-
Emit event when new contact is created
Declaration
Swift
nonisolated public var newContact: AnyPublisher<QNContact, Never> { get } -
Emit event when a contact is updated
Declaration
Swift
nonisolated public var contactUpdated: AnyPublisher<QNContact, Never> { get } -
Emit event when a contact is deleted
Declaration
Swift
nonisolated public var contactDeleted: AnyPublisher<QNContact, Never> { get } -
Subscribes to the external presence updates of a personal contact from the specified [contactId].
This function validates that the contact exists and belongs to a [Personal] source before establishing the subscription. It uses a shared subscription mechanism to optimize resources.
Declaration
Parameters
contactIdContact Id to be subscribed to.
Return Value
A Publisher to manage the lifecycle of the presence stream.
-
getContacts(using:AsynchronousfetchPresences: fromCache: ) Fetches and synchronizes contacts from multiple address book sources.
Throws
QNGenericError.internalErrorif the repository instance is deallocated, or service-specific errors during execution.Declaration
Parameters
sourcesThe specific address book sources to query. If
nil, the SDK’s default configuration is used.fetchPresencesExplicit flag to enable/disable presence fetching. If
nil, follows the SDK configuration.fromCacheIf
true(default), attempts to retrieve data from local storage before hitting the network.Return Value
An array of
QNContactobjects fully populated with domain data and presence info. -
getPersonalContact(associatedTo:Asynchronous) Retrieves the personal contact associated with a specific user.
This method orchestrates calls to the address book and presence services to construct a complete domain model of a contact.
Throws
Throws:
QNGenericError: If the service instance was deallocated (selfis nil).- Service-specific errors encountered during the address book fetch or presence lookup.
Note
Presence data is fetched with
fromCache: trueto optimize performance.Declaration
Parameters
userThe
QNUserinstance used to identify the contact.Return Value
A mapped
QNContactobject if found; otherwise,nil. -
add(contact:Asynchronous) -
update(contact:Asynchronous) -
delete(contact:Asynchronous) Remove a contact
Declaration
Swift
public func delete(contact: QNContact) async throwsParameters
contactContact to remove