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()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 outbound message has nopostback, emptytext, and emptyattachments.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 -> ChatThreadProviderReturn Value
ChatThreadProviderwith 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
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 outbound message has nopostback, emptytext, and emptyattachments.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 -> ChatThreadProviderParameters
customFieldsThe custom fields to be saved with thread creation.
Return Value
ChatThreadProviderwith 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
invalidThreaderror.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: String?) async 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.
-
The delegate for the chat thread provider based on chat thread’s unique identifier
Throws
invalidThreadif the provided ID for the thread was invalid, so the action could not be performed.Declaration
Swift
func provider(for threadId: String) throws -> any ChatThreadProviderParameters
threadIdThe 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
invalidThreadif the provided ID for the thread was invalid, so the action could not be performed.Declaration
Swift
func provider(for thread: ChatThread) throws -> any ChatThreadProviderParameters
threadThe chat thread for which to retrieve the provider.
Return Value
The provider for the chat thread.
View on GitHub