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
unsupportedChannelConfigif the method being called is not supported with the current channel configuration.Throws
missingPreChatCustomFieldsif the server requires to fill-up some contact custom fields before initializing chat thread.Throws
illegalThreadStateif the chat thread is not in the correct state.Throws
attachmentErrorif the provided attachment was unable to be sent.Throws
notConnectedif an attempt was made to use a method without connecting first. Make sure you call theconnectmethod first.Throws
customerAssociationFailureif the SDK could not get customer identity and it may not have been set.Throws
missingParameter(_:)if attachments uploadurlhas not been set properly or attachment uploaded data object is missing.Throws
serverErrorif 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/noSuchFileif an attached file could not be found.Throws
invalidFileSizeif size of the attachment exceeds the allowed sizeThrows
invalidFileTypeif type of the attachment is not included in the allowed file MIME typeThrows
invalidDataif 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.badServerResponseif the URL Loading system received bad data from the server.Throws
NSErrorobject that indicates why the request failedThrows
An error in the Cocoa domain, if
urlcannot be read.Throws
An error if any value throws an error during encoding.
Declaration
Swift
@discardableResult func create() async throws -> ChatThreadReturn 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.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
unsupportedChannelConfigif the method being called is not supported with the current channel configuration.Throws
missingPreChatCustomFieldsif the server requires to fill-up some contact custom fields before initializing chat thread.Throws
illegalThreadStateif the chat thread is not in the correct state.Throws
attachmentErrorif the provided attachment was unable to be sent.Throws
notConnectedif an attempt was made to use a method without connecting first. Make sure you call theconnectmethod first.Throws
customerAssociationFailureif the SDK could not get customer identity and it may not have been set.Throws
missingParameter(_:)if attachments uploadurlhas not been set properly or attachment uploaded data object is missingThrows
serverErrorif 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/noSuchFileif an attached file could not be found.Throws
invalidFileSizeif size of the attachment exceeds the allowed sizeThrows
invalidFileTypeif type of the attachment is not included in the allowed file MIME typeThrows
invalidDataif 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.badServerResponseif the URL Loading system received bad data from the server.Throws
NSErrorobject that indicates why the request failedThrows
An error in the Cocoa domain, if
urlcannot be read.Throws
An error if any value throws an error during encoding.
Declaration
Swift
@discardableResult func create(with customFields: [String : String]) async throws -> ChatThreadParameters
customFieldsThe 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
UUIDfor a non existing thread, it throwsinvalidThreaderror.Warning
Should only be used when opening a thread for multithreaded channel configuration or to reconnect after returning from the background.
Throws
notConnectedif an attempt was made to use a method without connecting first. Make sure you call theconnectmethod first.Throws
customerAssociationFailureif the SDK could not get customer identity and it may not have been set.Throws
invalidThreadif the provided ID for the thread was invalid, so the action could not be performed.Throws
invalidDatawhen 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?) throwsParameters
idThe 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
notConnectedif an attempt was made to use a method without connecting first. Make sure you call theconnectmethod first.Throws
unsupportedChannelConfigif the method being called is not supported with the current channel configuration.Throws
invalidThreadif the provided ID for the thread was invalid, so the action could not be performed.Throws
illegalThreadStateif the chat thread is not in the correct state.Throws
invalidDatawhen 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) throwsParameters
nameThe new name for the thread.
idThe 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
notConnectedif an attempt was made to use a method without connecting first. Make sure you call theconnectmethod first.Throws
illegalThreadStateif the chat thread is not in the correct state.Throws
customerAssociationFailureif the SDK could not get customer identity and it may not have been set.Throws
unsupportedChannelConfigif the method being called is not supported with the current channel configuration.Throws
invalidThreadif the provided ID for the thread was invalid, so the action could not be performed.Throws
invalidDatawhen 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
OperationErrorif there is any operaton error received from the BE.Declaration
Swift
func archive(_ thread: ChatThread) throwsParameters
threadThe thread to load.
-
Reports that the most recent message of the specified thread was read by the customer.
Throws
notConnectedif an attempt was made to use a method without connecting first. Make sure you call theconnectmethod first.Throws
customerAssociationFailureif the SDK could not get customer identity and it may not have been set.Throws
invalidDatawhen 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) throwsParameters
threadThe thread to load.
-
Invoke this when the customer wishes to end conversation.
Declaration
Swift
func endContact(_ thread: ChatThread) throwsParameters
threadThe thread to be close.
Warning
Should only be used on a channel configured for live chat.Throws
notConnectedif an attempt was made to use a method without connecting first. Make sure you call theconnectmethod first.Throws
customerAssociationFailureif the SDK could not get customer identity and it may not have been set.Throws
unsupportedChannelConfigif the method being called is not supported with the current channel configuration.Throws
missingParameter(_:)if thecontactIdhas not been set properly or it was unable to unwrap it as a required type.Throws
invalidDatawhen 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
notConnectedif an attempt was made to use a method without connecting first. Make sure you call theconnectmethod first.Throws
customerAssociationFailureif the SDK could not get customer identity and it may not have been set.Throws
illegalThreadStateif the chat thread is not in the correct state.Throws
invalidDatawhen 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) throwsParameters
didStartIndicator for start of finish typing.
threadThe thread where typing was started.
View on GitHub