ChatThreadListProvider

public protocol ChatThreadListProvider : Sendable

The provider for thread related properties and methods.

  • The dynamic pre-chat survey element with title and custom fields.

    To fill in the parameters of the pre-chat survey, use the create(with:) method.

    Declaration

    Swift

    var preChatSurvey: PreChatSurvey? { get }
  • The provider for chat fields related properties and methods.

    Declaration

    Swift

    var customFields: ContactCustomFieldsProvider { get }
  • The list of all chat threads.

    Declaration

    Swift

    func get() -> [ChatThread]

    Return Value

    List of chat threads if any exist.

  • create() Asynchronous

    Creates a new thread by sending an initial message to the thread.

    Warning

    If attempted on a channel that only supports a single thread, this will fail once a thread is already created.

    Warning

    Channel might have configured dynamic pre-chat survey with required contact custom fields. These identifiers and values must be sent. To fill in the parameters of the pre-chat survey, use the create(with:) method. Otherwise; this method throws missingPreChatCustomFields.

    Throws

    unsupportedChannelConfig if the method being called is not supported with the current channel configuration.

    Throws

    missingPreChatCustomFields if the server requires to fill-up some contact custom fields before initializing chat thread.

    Throws

    illegalThreadState if the chat thread is not in the correct state.

    Throws

    attachmentError if the provided attachment was unable to be sent.

    Throws

    notConnected if an attempt was made to use a method without connecting first. Make sure you call the connect method first.

    Throws

    customerAssociationFailure if the SDK could not get customer identity and it may not have been set.

    Throws

    missingParameter(_:) if attachments upload url has not been set properly or attachment uploaded data object is missing.

    Throws

    serverError if the server experienced an internal error and was unable to perform the action.

    Throws

    invalidParameter(_:) if the outbound message has no postback, empty text, and empty attachments.

    Throws

    invalidFileSize if size of the attachment exceeds the allowed size

    Throws

    invalidFileType if type of the attachment is not included in the allowed file MIME type

    Throws

    invalidData if the conversion from object instance to data failed when the Data object cannot be successfully converted to a valid UTF-8 string

    Throws

    EncodingError.invalidValue(_:_:) if the given value is invalid in the current context for this format.

    Throws

    URLError.badServerResponse if the URL Loading system received bad data from the server.

    Throws

    NSError object that indicates why the request failed

    Throws

    An error in the Cocoa domain, if url cannot be read.

    Throws

    An error if any value throws an error during encoding.

    Declaration

    Swift

    @discardableResult
    func create() async throws -> ChatThreadProvider

    Return Value

    ChatThreadProvider with newly created thread.

  • create(with:) Asynchronous

    Creates a new thread with custom fields by sending an initial message to the thread.

    Channel might have configured dynamic pre-chat survey with required contact custom fields. These values with its identifiers has to be sent in this method. Otherwise; this method throws missingPreChatCustomFields.

    Note

    This method can be used for providing regular contact custom fields (ContactCustomFieldsProvider), pre-chat custom fields (PreChatSurvey) or both.

    Warning

    If attempted on a channel that only supports a single thread, this will fail once a thread is already created.

    Throws

    unsupportedChannelConfig if the method being called is not supported with the current channel configuration.

    Throws

    missingPreChatCustomFields if the server requires to fill-up some contact custom fields before initializing chat thread.

    Throws

    illegalThreadState if the chat thread is not in the correct state.

    Throws

    attachmentError if the provided attachment was unable to be sent.

    Throws

    notConnected if an attempt was made to use a method without connecting first. Make sure you call the connect method first.

    Throws

    customerAssociationFailure if the SDK could not get customer identity and it may not have been set.

    Throws

    missingParameter(_:) if attachments upload url has not been set properly or attachment uploaded data object is missing

    Throws

    serverError if the server experienced an internal error and was unable to perform the action.

    Throws

    invalidParameter(_:) if the outbound message has no postback, empty text, and empty attachments.

    Throws

    invalidFileSize if size of the attachment exceeds the allowed size

    Throws

    invalidFileType if type of the attachment is not included in the allowed file MIME type

    Throws

    invalidData if the conversion from object instance to data failed or when the Data object cannot be successfully converted to a valid UTF-8 string

    Throws

    EncodingError.invalidValue(_:_:) if the given value is invalid in the current context for this format.

    Throws

    URLError.badServerResponse if the URL Loading system received bad data from the server.

    Throws

    NSError object that indicates why the request failed

    Throws

    An error in the Cocoa domain, if url cannot be read.

    Throws

    An error if any value throws an error during encoding.

    Declaration

    Swift

    @discardableResult
    func create(with customFields: [String : String]) async throws -> ChatThreadProvider

    Parameters

    customFields

    The custom fields to be saved with thread creation.

    Return Value

    ChatThreadProvider with newly created thread.

  • load(with:) Asynchronous

    Loads the a thread for the customer and gets messages.

    Warning

    If method receives identifier for a non existing thread, it throws invalidThread error.

    Warning

    Should only be used when opening a thread for multithreaded channel configuration or to reconnect after returning from the background.

    Throws

    notConnected if an attempt was made to use a method without connecting first. Make sure you call the connect method first.

    Throws

    customerAssociationFailure if the SDK could not get customer identity and it may not have been set.

    Throws

    invalidThread if the provided ID for the thread was invalid, so the action could not be performed.

    Throws

    invalidData when the Data object cannot be successfully converted to a valid UTF-8 string

    Throws

    EncodingError.invalidValue(_:_:) if the given value is invalid in the current context for this format.

    Declaration

    Swift

    func load(with id: String?) async throws

    Parameters

    id

    The id of the thread to load. Optional, if omitted, it will attempt to load the customer’s active thread. If there is no active thread, this returns an error.

  • The delegate for the chat thread provider based on chat thread’s unique identifier

    Throws

    invalidThread if the provided ID for the thread was invalid, so the action could not be performed.

    Declaration

    Swift

    func provider(for threadId: String) throws -> any ChatThreadProvider

    Parameters

    threadId

    The chat thread’s for which to retrieve the provider.

    Return Value

    The provider for the chat thread.

  • The delegate for the chat thread provider based on the chat thread object.

    Throws

    invalidThread if the provided ID for the thread was invalid, so the action could not be performed.

    Declaration

    Swift

    func provider(for thread: ChatThread) throws -> any ChatThreadProvider

    Parameters

    thread

    The chat thread for which to retrieve the provider.

    Return Value

    The provider for the chat thread.