Chat methods

Sending a message:

Variable Type Description
Message String

Message text

MessageId String

Message ID. After sending with the identifier, the loadingMessageId parameter will be filled with the passed identifier in the received message. This will help you match the sent and received messages.

Example:

usedesk.sendMessage("hi, how are you?", messageId: "123456789")

Sending a file:

VariableTypeDescription
fileNameString

Filename

dataDataFile in the Data format
MessageIdString

Message ID. After sending with the identifier, the loadingMessageId parameter will be filled with the passed identifier in the received message. This will help you match the sent and received messages.

Multiple files are sent in separate messages.

Example:

usedesk.sendFile(fileName: "file.png", data: imageData, messageId: "123456789", status: {success, error in })

The block returns the following parameters:

Variable Type Description
Bool

Sending status

String Error description

The usedesk.sendMessage(_, withFileName: , fileType: , contentBase64: ) method removed.

The history of messages in the current chat:

The message history is available after chat initialization in the historyMess parameter= [Message] is an object that stores all information about the message

Example:

usedesk.historyMess
A maximum number of attachments:

You can change the maximum number of attached files using the maxCountAssets variable.

Example:

usedesk.maxCountAssets = 5


Connection status:

Example:

usedesk.connectBlock = { success, error in
}

The block returns the following parameters:

Variable Type Description
Success Bool –°onnection status
Error String Error type
New incoming message:
Variable Type Description
incoming Bool

Incoming message flag

outgoing Bool

Outgoing message flag

text String The text of the message
picture_image UIImage The picture
buttons [UDMessageButton]

An array of objects with button parameters

Error String Error type

Example:

usedesk.newMessageBlock { success, message in
}

Submitting CSI Assessment:

Variable Type
Description
status Bool True - like, false - dislike
message_id Int

Message ID (UDMessage.messageId) in which the score is given

Example:

usedesk!.sendMessageFeedBack(true)


Connection Errors Block:
Example:
usedesk.errorBlock = {errors in
}
The end of the session:

Completely clears all sdk parameters, stops working websockets.

usedesk.releaseChat()
Closing a chat:

Clears message history, terminates WebSockets.

usedesk.closeChat()

Operators ended the call

The block returns the following parameters:

Variable Type Description
message UDMessage

Message with type 4 - the user ended the conversation

Example:

usedesk.feedbackMessageBlock = { message in
}

Localization

SDK supports four languages: Russian, English, Portuguese, Spanish. You can transfer your language dictionary. You can view the keys and current locales in the UDLocalizeManager. If you pass your dictionary, it must contain all the keys of the default localization.

Settings

You can restrict the types of content a customer sends, such as blocking videos or photos or both. To do this, select the value of the corresponding variable: isSupportedAttachmentOnlyPhoto (Bool) or isSupportedAttachmentOnlyVideo (Bool).

Example:

usedesk.isSupportedAttachmentOnlyPhoto = true

There is the isOpenSDKUI parameter, which shows whether the SDK windows are currently open.

Example:

usedesk.isOpenSDKUI