ChatThreadProvider

public protocol ChatThreadProvider : Sendable

The provider for message related properties and methods.

  • The delegate for the chat thread provider.

    Declaration

    Swift

    var chatThread: ChatThread { get }
  • loadMoreMessages() Asynchronous

    Loads additional messages in the thread.

    Throws

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

    Throws

    noMoreMessages if there aren’t any other messages, so additional messages could not be loaded.

    Throws

    invalidOldestDate if Thread is missing the timestamp of when the message was created.

    Throws

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

    Throws

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

    Throws

    eventTimeout if the SDK did not receive a response within the specified time.

    Throws

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

    Declaration

    Swift

    func loadMoreMessages() async throws
  • send(_:) Asynchronous

    Sends a message in the chat thread through CXone chat.

    Throws

    illegalChatState if the chat thread is already closed.

    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

    eventTimeout if the SDK did not receive a response within the specified time.

    Throws

    invalidAccessToken if the credential needs a refresh but nothing is available to perform it — no registered token delegate listener for the implicit flow, or no socket delegate at all.

    Throws

    invalidRefreshToken(_:) if the explicit-PKCE credential was expired and the refresh grant to renew it was rejected — the app must re-authenticate before it can send again.

    Throws

    transactionTokenRequestFailed(statusCode:) if the explicit-PKCE credential was expired and renewing it failed for any other reason.

    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

    func send(_ message: OutboundMessage) async throws

    Parameters

    message

    The content of the message.

  • updateName(_:) Asynchronous

    Updates the name for the thread.

    Warning

    Should only be used on a channel configured for multiple threads.

    Throws

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

    Throws

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

    Throws

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

    Throws

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

    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 updateName(_ name: String) async throws

    Parameters

    name

    The new name for the thread.

  • archive() Asynchronous

    Archives the thread from the list of all threads.

    Warning

    Should only be used on a channel configured for multiple threads.

    Throws

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

    Throws

    illegalChatState if the chat thread is already closed.

    Throws

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

    Throws

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

    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

    eventTimeout if the SDK did not receive a response within the specified time.

    Throws

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

    Throws

    An error if the backend rejects the archive request.

    Declaration

    Swift

    func archive() async throws
  • markRead() Asynchronous

    Reports that the most recent message of the specified thread was read by the customer.

    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

    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 markRead() async throws
  • endContact() Asynchronous

    Invoke this when the customer wishes to end conversation.

    Warning

    Should only be used on a channel configured for live chat.

    Throws

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

    Throws

    illegalChatState if the channel is not configured for live chat.

    Throws

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

    Throws

    missingParameter(_:) if the contactId has not been set properly or it was unable to unwrap it as a required type.

    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 endContact() async throws
  • reportTypingStart(_:) Asynchronous

    Reports that the customer has started or finished typing in the specified chat thread.

    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

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

    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 reportTypingStart(_ didStart: Bool) async throws

    Parameters

    didStart

    Indicator for start of finish typing.

  • sendTranscript(to:) Asynchronous

    Sends a transcript to the specified email address.

    This method validates the email and initiates delivery of the conversation transcript.

    Throws

    notConnected If the method is called before establishing a connection. Ensure you call the connect() method first.

    Throws

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

    Throws

    sendTranscriptFailed If the feature is disabled, the provided email is invalid, or an error occurs on the backend.

    Throws

    missingParameter(_:) If contactID is not set properly.

    Throws

    customerAssociationFailure If the SDK cannot retrieve the customer identity, which may not have been set.

    Declaration

    Swift

    func sendTranscript(to email: String) async throws

    Parameters

    email

    The recipient’s email address.