ChatThreadsProvider
public protocol ChatThreadsProvider
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 message related properties and methods.
Declaration
Swift
var messages: MessagesProvider { 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()
AsynchronousCreates 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 throwsmissingPreChatCustomFields
.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 theconnect
method first.Throws
customerAssociationFailure
if the SDK could not get customer identity and it may not have been set.Throws
missingParameter(_:)
if attachments uploadurl
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 the outbound message has nopostback
, emptytext
, and emptyattachments
.Throws
CXoneChatError/noSuchFile
if an attached file could not be found.Throws
invalidFileSize
if size of the attachment exceeds the allowed sizeThrows
invalidFileType
if type of the attachment is not included in the allowed file MIME typeThrows
invalidData
if the conversion from object instance to data failed when the Data object cannot be successfully converted to a valid UTF-8 stringThrows
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 failedThrows
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 -> ChatThread
Return Value
Newly created
ChatThread
-
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
.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 theconnect
method first.Throws
customerAssociationFailure
if the SDK could not get customer identity and it may not have been set.Throws
missingParameter(_:)
if attachments uploadurl
has not been set properly or attachment uploaded data object is missingThrows
serverError
if the server experienced an internal error and was unable to perform the action.Throws
invalidParameter(_:)
if the the outbound message has nopostback
, emptytext
, and emptyattachments
.Throws
CXoneChatError/noSuchFile
if an attached file could not be found.Throws
invalidFileSize
if size of the attachment exceeds the allowed sizeThrows
invalidFileType
if type of the attachment is not included in the allowed file MIME typeThrows
invalidData
if the conversion from object instance to data failed or when the Data object cannot be successfully converted to a valid UTF-8 stringThrows
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 failedThrows
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 -> ChatThread
Parameters
customFields
The custom fields to be saved with thread creation.
Return Value
Newly created
ChatThread
-
Loads the a thread for the customer and gets messages.
Warning
If method receives
UUID
for a non existing thread, it throwsinvalidThread
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 theconnect
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 stringThrows
EncodingError.invalidValue(_:_:)
if the given value is invalid in the current context for this format.Declaration
Swift
func load(with id: UUID?) 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.
-
Updates the name for a 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 theconnect
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 stringThrows
EncodingError.invalidValue(_:_:)
if the given value is invalid in the current context for this format.Declaration
Swift
func updateName(_ name: String, for id: UUID) throws
Parameters
name
The new name for the thread.
id
The unique identifier of the thread to load.
-
Archives a 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 theconnect
method first.Throws
illegalThreadState
if the chat thread is not in the correct state.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 stringThrows
EncodingError.invalidValue(_:_:)
if the given value is invalid in the current context for this format.Throws
OperationError
if there is any operaton error received from the BE.Declaration
Swift
func archive(_ thread: ChatThread) throws
Parameters
thread
The thread to load.
-
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 theconnect
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 stringThrows
EncodingError.invalidValue(_:_:)
if the given value is invalid in the current context for this format.Declaration
Swift
func markRead(_ thread: ChatThread) throws
Parameters
thread
The thread to load.
-
Invoke this when the customer wishes to end conversation.
Declaration
Swift
func endContact(_ thread: ChatThread) throws
Parameters
thread
The thread to be close.
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 theconnect
method first.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
missingParameter(_:)
if thecontactId
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. -
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 theconnect
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 stringThrows
EncodingError.invalidValue(_:_:)
if the given value is invalid in the current context for this format.Declaration
Swift
func reportTypingStart(_ didStart: Bool, in thread: ChatThread) throws
Parameters
didStart
Indicator for start of finish typing.
thread
The thread where typing was started.