Rox.Chat Mobile SDK Reference Guide for iOS Applications
The revision corresponds to the current version of Mobile SDK 3 for iOS.
N.B.
Answers to the most common questions are given in this article.
Class Roxchat
A set of static methods that are used when creating a session object and to handle push notifications from the Rox.Chat service
Class method newSessionBuilder()
Method needed to get a SessionBuilder
object, which in turn is needed to create an instance of the RoxchatSession
class
Class method parse(remoteNotification:visitorId:)
A method used to convert an object representing a push notification to an iOS app into an object of class RoxchatRemoteNotification
.
The remoteNotification
parameter is a dictionary of type [AnyHashable: Any]
(the same dictionary type is passed to the application(_:didReceiveRemoteNotification:)
method in the userInfo
parameter in the AppDelegate
class of the iOS app). You must pass the value of the userInfo
parameter, the above mentioned method of the AppDelegate
class in an unmodified form to the parameter.
Returns an object of class RoxchatRemoteNotification
or nil
if the value of the remoteNotification
parameter does not match the format of the push notification received from the Rox.Chat service, or the notification contains no payload.
As a preliminary check if the remoteNotification
parameter is a push notification received from the Rox.Chat service, the isRoxchat(remoteNotification:)
method can be called.
Class method isRoxchat(remoteNotification:)
A method to find out if the object representing a push notification in the iOS app is a push notification received from the Rox.Chat service.
The remoteNotification
parameter is a dictionary of type [AnyHashable: Any]
(the same type of dictionary is passed to the application(_:didReceiveRemoteNotification:)
method in the userInfo
parameter in the AppDelegate
class of the iOS app). You must pass the value of the userInfo
parameter, the above mentioned method of the AppDelegate
class in an unmodified form to the parameter.
Returns a boolean value: true
- if the value of the remoteNotification
parameter is a received push notification from the Rox.Chat service, false
- if it is not.
Enumerated type RemoteNotificationSystem
Push notification systems that can be passed as a parameter to the SessionBuilder
set(remoteNotificationSystem:)
instance method.
Case APNS
Corresponds to Apple Push Notification System.
Case NONE
Corresponds to the situation when the application does not need to receive push notifications from the Rox.Chat service.
Class SessionBuilder
A class whose instance is used to get an instance of class RoxchatSession
. An instance of the class is obtained using the newSessionBuilder()
method of the Roxchat
class.
Class method set(notFatalErrorHandler:)
A method to set an object obeying the NotFatalErrorHandler
protocol, which will be responsible for handling session instance creation errors that may be raised by the Rox.Chat service.
The notFatalErrorHandler
parameter is any class that implements the NotFatalErrorHandler
interface.
Returns the same instance of class SessionBuilder
, but with the NotFatalErrorHandler
object installed. To get an instance of class RoxchatSession
, the method call is optional.
Class method set(accountName:)
The method is required to set the account name in the Rox.Chat system when creating a session.
The accountName
parameter is the name of the client's account in the Rox.Chat system. Usually it is a URL of the server (for example, https://demo.roxchat.ru
), but it can also be an account name in one word (for example, demo
), if the server is in the domain roxchat.ru
. The parameter type is String
.
Returns the same instance of SessionBuilder
class, but with the account name set.
To get an instance of RoxchatSession
, the method call is mandatory.
Class method set(location:)
The method is required to set the location initially used when creating a session.
The location
parameter is the location within the Rox.Chat service that will be used when chatting. The type of the parameter is String
. Most likely, you can use mobile
and/or default
values right away. To create and further use additional locations, you should contact the Rox.Chat service support team.
Returns the same instance of SessionBuilder
class, but with the name of the used location set.
To get an instance of RoxchatSession
, the method call is mandatory.
Class method set(appVersion:)
The method is used to set the version of the client application if they need to be distinguished in the context of the Rox.Chat service.
The appVersion
parameter is the version of the client application or nil
. The parameter type is an optional String
.
Returns the same instance of the SessionBuilder
class but with the client application version installed if the appVersion
parameter is not nil
, and an unmodified instance of the SessionBuilder
class if the appVersion parameter is nil
.
It is optional to call the method to get an instance of class RoxchatSession
.
Class method set(visitorFieldsJSONString:)
The method is used to authorize the visitor internally.
Without calling this method when creating a session object, the user will be anonymous, with a randomly generated ID. This ID is stored in the application settings, and if these settings are lost (e.g. when reinstalling the application), all data (message history) will be lost.
All data of an authorized user is saved and will be available when authorizing from any device.
Parameter jsonString
- fields of user authorization data in JSON
format, type - String
. Detailed information about these fields (including which ones are mandatory and how they should be formed) can be found in this article.
Returns the same instance of class SessionBuilder
, but with the visitor's authorization credentials set.
It is optional to call this method to get an instance of class RoxchatSession
.
This method cannot be called at the same time as the set(providedAuthorizationTokenStateListener:providedAuthorizationToken:)
method.
Class method set(visitorFieldsJSONData jsonData:)
A method completely similar to the set(visitorFieldsJSONString:)
method except for the parameter: the jsonData
parameter is of type Data
(given from JSON
format). Which of the two methods to use is irrelevant.
Class method set(providedAuthorizationTokenStateListener:providedAuthorizationToken:)
When a client application provides its own visitor authorization mechanism, this can be implemented by passing a special token instead of visitor fields.
This method passes a protocol object ProvidedAuthorizationTokenStateListener
and a token. It is not necessary to pass the token: if you omit the second parameter, the token will be generated by the library.
Returns the same instance of class SessionBuilder
, but with the ProvidedAuthorizationTokenStateListener
object and the token of the visitor's authorization client system installed.
It is optional to call this method to get an instance of class RoxchatSession
.
This method cannot be called concurrently with the set(visitorFieldsJSONString:)
or set(visitorFieldsJSONData:)
methods.
Class method set(pageTitle:)
A method to set the operator-side chat title when creating a session instance. If the method was not called when the session instance was created, the title will take the default value of iOS Client
.
The pageTitle
parameter is the operator-side chat title. The parameter type is String
.
Returns the same instance of class SessionBuilder
, but with the operator-side chat title set.
It is optional to call this method to get an instance of class RoxchatSession
.
Class method set(fatalErrorHandler:)
A method to set an object obeying the FatalErrorHandler
protocol, which will be responsible for handling session instance errors that may be called by the Rox.Chat service.
The fatalErrorHandler
parameter is optional; any class that obeys the FatalErrorHandler
protocol, or nil
if the FatalErrorHandler
protocol methods will not be used in the application.
Returns the same instance of class SessionBuilder
, but with the FatalErrorHandler
object installed.
It is optional to call the method to get an instance of class RoxchatSession
.
Class method set(remoteNotificationSystem:)
A method to specify, when creating a session, whether the application will receive push notifications from the Rox.Chat service and, if so, which push notification system the application will use to do so. (See the RemoteNotificationSystem
enumerated type in the Roxchat
class.)
The remoteNotificationSystem
parameter is the corresponding value of type RemoteNotificationSystem
of class Roxchat
.
Requires a previously obtained instance of class SessionBuilder
. If this method is called and the value of the remoteNotificationSystem parameter is other than NONE
, it is mandatory to call the set(deviceToken:)
method when creating an instance of the session.
To get an instance of class RoxchatSession
, calling the method set(deviceToken:)
is optional. If the method was not called when creating a session, the Rox.Chat service will not send push notifications to the application (similarly to the value of the remoteNotificationSystem
parameter NONE
).
Class method set(deviceToken:)
A method that can be used to specify a device token for the application to receive push notifications from the Rox.Chat service when creating a session.
The deviceToken
parameter is the device token used to receive push notifications in the application. Type - optional String
in hexadecimal format, without service characters and spaces.
An example of casting the device token value to the desired form from the value in Data
format obtained by the application(_:,didRegisterForRemoteNotificationsWithDeviceToken:)
method of the AppDelegate
class of an application:
let deviceToken = deviceToken.map { String(format: "%02.2hhx", $0) }.joined()
Returns the same instance of the SessionBuilder
class, but with the device token value set.
For an application to receive push notifications from the Rox.Chat service, calling this method is not sufficient: a call to the set(remoteNotificationSystem:)
method is also required.
To get an instance of class RoxchatSession
, calling this method is not required.
Class method set(isLocalHistoryStoragingEnabled:)
By default, the session stores message history on the device (in the SQLite repository associated with the application). If this functionality needs to be disabled for any purpose, this method is used with the isLocalHistoryStoragingEnabled
parameter value false
.
The isLocalHistoryStoragingEnabled
parameter is a boolean variable indicating whether message history should be stored locally (value true
) or not (value false
).
Returns the same instance of class SessionBuilder
, but with the value of the corresponding option set manually.
It is optional to call the method to get an instance of class RoxchatSession
. Not calling the method is the same as calling it with the isLocalHistoryStoragingEnabled
true
parameter value.
Class method set(isVisitorDataClearingEnabled:)
Method used to remove all existing user data during session instance creation.
The isVisitorDataClearingEnabled
parameter is a boolean variable indicating the need to clear user data (value true
) or its (need) absence (value false
).
Returns the same instance of class SessionBuilder
, but with the corresponding option value set manually.
It is optional to call the method to get an instance of class RoxchatSession
. Absence of method call is similar to its call with isVisitorDataClearingEnabled false
parameter value.
To get an instance of RoxchatSession
class, the method call is optional
Class method set(roxchatLogger:verbosityLevel:availableLogTypes:)
The method by which the RoxchatLogger
object is passed.
The verbosityLevel
parameter is the value of RoxchatLoggerVerbosityLevel
(may be omitted).
The availableLogTypes
parameter is the value of RoxchatLogType
(may be omitted).
Class method build()
A method that is called at the conclusion of the above methods to get an instance of RoxchatSession
.
Returns a RoxchatSession
object with the parameters set using the rest of the class instance methods.
Can throw errors like SessionBuilderError
.
Requires calling the set(accountName:)
and set(location:)
methods (in any order). Any other (in any order and combination) methods of the SessionBuilder
class instance may also be called beforehand.
Class method set(multivisitorSection:)
The method is used to get notifications for different visitors on the same device.
The multivisitorSection
parameter is a String
.
Returns the same instance of class SessionBuilder
, but with the corresponding option value set manually.
Class method set(roxchatAlert:)
The method is used to show standard error warnings.
The roxchatALert
parameter is a warning, the type is RoxchatAlert
.
Returns the same instance of class SessionBuilder
, but with the value of the corresponding option set there.
Class method set(mobileChatInstance:)
The method is used to set a new session inside the mobile application.
The mobileChatInstance
parameter is String
.
The default value is default
.
If you do not set this parameter and try to create a new session inside the mobile app, you will get the same session.
Returns the same instance of the SessionBuilder
class, but with the value of the corresponding option set manually.
Enumerated type RoxchatLogType
Possible log types. Used in the set(roxchatLogger:verbosityLevel:availableLogTypes:)
method.
Case networkRequest
Logs related to network requests.
Case messageHistory
Logs related to message history.
Case manualCall
Logs related to manual method calls.
Case undefined
Undefined type.
Enumerated type FileState
Used to define the state of a file.
Case error
Occurs when an error occurred while loading a file.
Case ready
Occurs when a file has been uploaded.
Case upload
Occurs when a file is being uploaded.
Case externalChecks
The file is checked by the server.
Enumerated type EditMessageError
Possible errors that can be passed to the error
parameter when calling the EditMessageCompletionHandler.onFailure(messageID:error:)
method.
Case UNKNOWN
Unknown error.
Case NOT_ALLOWED
The ability to edit messages is disabled on the server.
Case MESSAGE_EMPTY
The message being edited is empty.
Case MESSAGE_NOT_OWNED
The visitor can only edit their own messages. The specified identifier belongs to another message.
Case MAX_LENGTH_EXCEEDED
The server may reject the request if the message size exceeds the limit. The maximum message size is configurable on the server.
Case WRONG_MESSAGE_KIND
The visitor can only edit text messages.
Enumerated type RoxchatLoggerVerbosityLevel
Specifies the degree of informativeness of the entries passed to the RoxchatLogger
object.
Case VERBOSE
All available information will be passed to the RoxchatLogger
object with maximum informativeness level:
-
network connection configuration parameters;
-
URLs, HTTP methods and network request parameters;
-
HTTP codes, received data and errors of responses to network requests;
-
SQL queries and errors that occur with these queries;
-
complete information that may be useful in debugging, and additional notes.
Case DEBUG
All information needed for debugging will be passed to the RoxchatLogger
object with the required level of informativeness:
-
network connection configuration parameters;
-
URLs, HTTP methods and network request parameters;
-
HTTP codes, received data and errors of responses to network requests;
-
SQL queries and errors that occur with these queries;
-
complete information that may be useful for moderately informative debugging.
Case INFO
The RoxchatLogger
object will be passed background information, as well as all warnings and errors:
-
URLs, HTTP methods and network request parameters;
-
HTTP codes, received data and network request response errors;
-
SQL queries and errors generated by those queries.
Case WARNING
Only warnings and errors will be sent to the RoxchatLogger
object:
-
HTTP codes, received data, and network request response errors;
-
SQL queries and errors that occur with those queries.
Case ERROR
Only errors will be passed to the RoxchatLogger
object:
- HTTP codes and errors from responses to network requests that failed.
Enumerated type SessionBuilderError
The type values correspond to possible errors that may occur when calling the build()
method of the SessionBuilder
class.
Case NIL_ACCOUNT_NAME
Occurs when no account name value (or this value is nil
) was passed in when the session was created.
Case NIL_LOCATION
Occurs when no location name value (or this value is nil
) was passed in when the session was created.
Case INVALID_AUTHENTICATION_PARAMETERS
Occurs when an attempt was made to use both the default (see the set(visitorFieldsJSONString:)
and set(visitorFieldsJSONData:)
) and custom (see the [set(providedAuthenticATION_PARAMETERS
) methods) at the same time when creating a session. method set(providedAuthorizationTokenStateListener:providedAuthorizationToken:)
) of the visitor authorization system.
Case INVALIDE_HEX
Occurs when an invalid string in HEX
format is passed.
Case INVALID_REMOTE_NOTIFICATION_CONFIGURATION
Occurs when an invalid push service configuration occurred during session creation (the service to be used when receiving push notifications from Rox.Chat service other than NONE
was set (see the [set(remoteNOTIFICATION_CONFIGURATION_CONFIGURATION_CONFIGURATION_CONFIGURATION_CONFIGURATION_CONFIGURATION
method)). method set(remoteNotificationSystem:)
of class SessionBuilder
, but no device token value (or the value nil
) was passed - see method set(deviceToken:)
of class SessionBuilder
).)
Case UNKNOWN
Unknown error.
Enumerated type ButtonState
Used to define the state of a button.
Case showing
The button is being displayed.
Case showingSelected
The button is selected.
Case hidden
The button is hidden.
Enumerated type ButtonType
Used to define the type of a button.
Case URL
The button contains a link that will take the visitor to when the button is clicked.
Case insert
The button contains text that will be sent on behalf of the visitor when the button is clicked.
Protocol Configuration
Protocol is an abstraction that represents the configuration information of the chatbot keyboard buttons.
Method isActive()
A method that can be used to get information whether a button is active or not.
Returns true
if active and false
if not. The type is Bool
.
Method getButtonType()
A method that can be used to get information about the button type.
Returns the type of the button. The type is ButtonType
.
Method getData()
A method that can be used to get information about the button.
Returns information about the button. The type is String
.
Method getState()
A method that can be used to get information about the state of the button.
Returns information about the state of the button. Type - ButtonState
.
Protocol FileInfo
Contains information about attachments.
Method getContentType()
A method that can be used to get the MIME
type of an attachment.
Returns the MIME
type of the attachment in text form or nil
. The type is an optional String
.
Method getFileName()
A method that can be used to get the name of the attachment file.
Returns the name of the attachment file in text form or nil
. The type is String
.
Method getImageInfo()
A method that can be used to get information about an image, if the attachment is one.
Returns an ImageInfo
object or nil
if the attachment is not an image.
Method getSize()
A method that can be used to get the size of the attachment file.
Returns the size of the attachment file in bytes or nil
. The type is optional Int64
.
Method getURL()
A method that can be used to get a link to download the attachment file. The link is only valid for the current session.
Returns the URL of the attachment file or nil
.
Method getGuid()
A method that can be used to get the guid
of the attachment file.
Returns the value in text form. The type is String
.
Protocol Keyboard
The protocol is an abstraction that provides the elements of a chatbot's keyboard.
Method getButtons()
A method that can be used to get a list of buttons for a keyboard element.
Returns a list of buttons. The type is KeyboardButton
.
Method getState()
A method that can be used to get the state of the keyboard.
Returns the state of the keyboard. The type is KeyboardState
.
Method getKeyboardResponse()
A method that can be used to get the button selected by the user.
Returns the button selected by the user. The type is optional KeyboardResponse
.
Protocol KeyboardButton
The protocol is an abstraction representing information about the chatbot's keyboard buttons.
Method getId()
A method that can be used to get the unique ID of a button in the chatbot keyboard.
Returns the ID in text form. The type is String
. Button ID can contain only Latin letters, digits, hyphen and underscore characters and must be no more than 24 characters long. The button ID generated on the Rox.Chat side has the UUID4
format, and the ID generated externally (including third-party bots) is only checked for compliance with the above criteria.
Method getText()
Method that can be used to get the text of a button in the chatbot keyboard.
Returns the name of the button in text form. The type is String
.
Method getConfiguration()
A method that can be used to get the configuration of a button in the chatbot keyboard. Type is optional Configuration
.
Protocol KeyboardRequest
The protocol is an abstraction representing information about the selected button in the chatbot keyboard.
Method getButton()
A method that can be used to retrieve the selected button of a keyboard element.
Returns a KeyboardButton
object.
Method getMessageId()
Method that can be used to get the ID of the message in which the button was selected.
Returns the name of the message ID in text form. The type is String
.
Protocol KeyboardResponse
The protocol is an abstraction representing information about the selected button in the chatbot keyboard.
Method getButtonId()
A method that can be used to get the unique ID of the selected button in the chatbot keyboard.
Returns the ID in text form. The type is String
.
Method getMessageId()
Method that can be used to get the ID of the message in which the button was selected.
Returns the name of the message ID in text form. The type is String
.
Protocol NotFatalErrorHandler
A protocol that provides methods to handle non-critical errors that may occur in the Rox.Chat service.
Method on(error:)
Called when a non-critical error of the Rox.Chat service occurs.
The error
parameter is an error of the Rox.Chat service. The type is RoxchatNotFatalError
.
Warning!
This method is called not from the main thread!
Method connectionStateChanged(connected:)
Called when the Rox.Chat service connection error occurs.
Warning!
This method is called not from the main thread!
Protocol Quote
Protocol is an abstraction representing information about a quoted message.
Method getAuthorId()
Use this method to get the author ID of the quoted message.
Returns the ID of the message. The type is an optional String
.
Method getMessageAttachment()
Use this method to get an attachment if it is a file sent by a visitor or operator (FILE_FROM_OPERATOR
or FILE_FROM_VISITOR
).
Returns information about the attachment. The type is optional FileInfo
.
Method getMessageTimestamp()
Use this method to get the time the message was sent.
Returns the number of milliseconds elapsed from the beginning of the epoch until the message is processed by the server. The type is the optional Date
.
Method getMessageId()
Use this method to get the unique ID of the quoted message.
It returns the ID of the message. The type is optional String
.
Method getMessageText()
Use this method to get the text of the message.
Returns the text of the message. The type is optional String
.
Method getMessageType()
Use this method to get the type of the quoted message.
Returns an optional value of the enumerated type MessageType
.
Method getSenderName()
Use this method to get the name of the sender of a message.
Returns the name of the sender of the message. The type is the optional String
.
Method getState()
Use this method to get the status of the quote.
Returns a value of enumerated type QuoteState
.
Enumerated type QuoteState
Used to determine the state of a quoted message.
Case PENDING
Occurs when the quote is being loaded.
Case FILLED
Occurs when the quote is loaded.
Case NOT_FOUND
Occurs when the quoted message is not found on the server.
Enumerated type NotFatalErrorType
Corresponds to the values of possible fatal errors that may occur in the Rox.Chat service (see the getErrorType()
method of the RoxchatNotFatalError
interface).
Case NO_NETWORK_CONNECTION
This error indicates that there is no network connection.
Case SERVER_IS_NOT_AVAILABLE
This error occurs when the server is unavailable.
Enumerated type KeyboardResponseError
Possible errors that can be passed to the error
parameter when calling the KeyboardResponseCompletionHandler.onFailure(error:)
method.
Case UNKNOWN
Unknown error.
Case NO_CHAT
A button from the chatbot keyboard was sent to the wrong chat.
Case BUTTON_ID_NOT_SET
The button ID is not set.
Case REQUEST_MESSAGE_ID_NOT_SET
The request message identifier is not set.
Case CAN_NOT_CREATE_RESPONSE
Unable to create a response.
Enumerated type KeyboardRequest
Used to determine the state of a quoted message.
Case PENDING
Occurs when the quoted message is loaded.
Case FILLED
Occurs when the quote is loaded.
Case NOT_FOUND
Occurs when the quoted message is not found on the server.
Enumerated type KeyboardState
Used to determine the state of the quoted message (see the getState()
method of the Keyboard
interface).
Case PENDING
Occurs when the keyboard is active and keys can be pressed.
Case CANCELLED
Occurs when the keyboard is inactive and keys cannot be pressed.
Case COMPLETED
Occurs when the keypad is inactive and one of the keys is selected.
Protocol EditMessageCompletionHandler
An object implementing this protocol can be passed to the completionHandler
parameter of the edit(message:text:completionHandler:)
method of the MessageStream
protocol.
Method onSuccess(messageID:)
Called when the call to the edit(message:text:completionHandler:)
method of the MessageStream
protocol succeeds.
The messageID
parameter is the ID of the corresponding message. The type is String
.
Method onFailure(messageID:error:)
Called when the edit(message:text:completionHandler:)
method of the MessageStream
protocol fails.
The messageID
parameter is the ID of the corresponding message. The type is String
.
The error
parameter - the error that prevented successful editing of the message. Type - EditMessageError
.
Protocol ProvidedAuthorizationTokenStateListener
If the client provides its own visitor authorization mechanism, this can be implemented by passing a special token that is used instead of visitor fields (see the set(visitorFieldsJSONString:)
and set(visitorFieldsJSONData:)
methods). The moment this token is generated (or receives a passed value), the update(providedAuthorizationToken:)
method is called. This means that the client service must pass this token to the Rox.Chat service.
This mechanism is not a self-sufficient implementation. The client service must support and implement methods to pass the token and visitor data to the Rox.Chat service.
Method update(providedAuthorizationToken:)
The method is called in two cases:
-
The token of the client authorization mechanism is provided or generated and it is required to be sent to the Rox.Chat service by the client.
-
Information is received from Rox.Chat service that the token used is unknown to it. This may happen, for example, if the token was not sent to the Rox.Chat service by the client's service or was not received by the Rox.Chat service. In this case the Rox.Chat service needs to provide the token and the visitor's data corresponding to it.
Protocol RoxchatSession
A protocol that allows manipulation of the current session. An instance of class RoxchatSession
is obtained using the methods of class SessionBuilder
.
Method resume()
When an instance of class RoxchatSession
is created, its corresponding session is in a suspended state. This method is required to start the session's network activity.
It may throw errors like AccessError
.
Necessary for the service to function fully in the application context.
Various methods MessageListener
, ChatStateListener
, CurrentOperatorChangeListener
, and LocationSettingsChangeListener
may be called as a result of the server response.
Method pause()
A method that is used to suspend the network activity of a session. If the session is already in a suspended state, the method does not perform any action.
May throw errors of type AccessError
.
The session must not be in a deactivated state for the method to be called.
Method destroy()
A method that is used to deactivate the session and class instance. Once this method is called, no methods related to the session can be used.
May throw errors like AccessError
.
Method getStream()
The method to call to retrieve the corresponding MessageStream
instance session.
For full use of the MessageStream
protocol methods, the session must not be suspended or deactivated (see the resume()
, pause()
, and destroy()
methods).
Method set(deviceToken:)
The method is used to set the device token to receive push notifications.
The deviceToken
parameter is the device token used to receive push notifications in the application. Type - optional String
in hexadecimal format, without service characters and spaces.
An example of casting the device token value to the desired form from the value in Data
format obtained by the application(_:didRegisterForRemoteNotificationsWithDeviceToken:)
method of the AppDelegate
class of an application:
let deviceToken = deviceToken.map { String(format: "%02.2hhx", $0) }.joined()
May throw errors like AccessError
.
The session must not be in a suspended or deactivated state to call the method (see resume()
, pause()
and destroy()
methods).
Method destroyWithClearVisitorData()
A method that is used to deactivate the session and class instance with the user information removed. Once this method is called, no methods related to the session can be used.
May throw errors like AccessError
.
Protocol MessageData
Contains a file attached to the message.
Method getAttachment()
Use this method to get an attachment if it is a file sent by a visitor or operator (MessageType
FILE_FROM_OPERATOR
or FILE_FROM_VISITOR
).
Returns an instance of class MessageAttachment
or nil
if the file is in the process of being sent.
Protocol MessageStream
The instance of the class by which the protocol methods are called exists only once within a session and is obtained using the getStream()
method of an instance of the RoxchatSession
class. The protocol methods are used directly for interacting with the Rox.Chat service (such as sending and receiving messages).To use the protocol methods, it is necessary that the session is not in suspended or deactivated state (see the resume()
, pause()
and destroy()
methods of the RoxchatSession
class).
Method startChat(customFields:)
Method starts a chat with the specified custom fields. In terms of the Rox.Chat service, it changes the current chat state, represented by the ChatState
type, to QUEUE
.
It can throw errors of type AccessError
.
Parameter customFields
- optional fields in JSON
format. The type is an optional String
.
The result may call the changed(state previousState:to newState:)
method of the ChatStateListener
protocol.
Method startChat(firstQuestion:customFields:)
The method starts a chat with the specified custom fields and simultaneously sends the visitor's first message.
In terms of the Rox.Chat service, changes the current chat state, represented by the ChatState
type, to QUEUE
.
It may throw errors like AccessError
.
If the account settings provide for welcome messages, no welcome messages will be received before the chat is started (by the startChat
series methods or with the first message).
The firstQuestion
parameter is the user's first message. The type is an optional String
.
Parameter customFields
- additional fields in JSON
format. The type is optional String
.
The result may call the changed(state previousState:to newState:)
method of the ChatStateListener
protocol.
Method startChat(departmentKey:customFields:)
Method starts a chat with the specified department and the specified optional fields.
In terms of the Rox.Chat service, it changes the current chat state, represented by the ChatState
type, to QUEUE
.
It can throw errors of type AccessError
.
When a user sends a message or file, the chat starts automatically, but if the current state of VisitSessionState
is DEPARTMENT_SELECTION
, the chat should be started using this method.
The departmentKey
parameter is passed the value of the department key, which can be obtained using the getKey()
method of the Department
protocol.
The customFields
parameter is optional fields in JSON
format. The type is an optional String
.
The result may call the changed(state previousState:to newState:)
method of the ChatStateListener
protocol.
Method startChat(departmentKey:firstQuestion:customFields:)
The method starts a chat with the specified department and the specified optional fields, and sends the visitor's first message at the same time.
In terms of the Rox.Chat service, changes the current chat state, represented by the ChatState
type, to QUEUE
.
It may throw errors of type AccessError
.
When a user sends a message or file, the chat starts automatically, but if the current state of VisitSessionState
is DEPARTMENT_SELECTION
, the chat should be started using this method.
The departmentkey
parameter contains the value of the department key, which can be obtained using the getKey()
method of the Department
protocol.
If the account settings provide for welcome messages, no welcome messages will be received before the chat is started (by methods in the startChat
series or with the first message).
The firstQuestion
parameter is the user's first message. The type is an optional String
.
Parameter customFields
- additional fields in JSON
format. The type is optional String
.
The result may call the changed(state previousState:to newState:)
method of the ChatStateListener
protocol.
Method send(message:completionHandler:)
Corresponds to the send(message:isHintQuestion:)
method with the isHintQuestion
parameter omitted.
The completionHandler
parameter is an object that implements the protocol methods of SendMessageCompletionHandler
. The type is optional.
Method sendKeyboardRequest(button:message:completionHandler:)
The method is used to send the selected item in the chatbot keyboard to the Rox.Chat service.
May throw errors of type AccessError
.
The button
parameter is an item in the chatbot keyboard. The type is KeyboardButton
.
Parameter message
- message. Type - Message
.
The completionHandler
parameter is an object that implements the SendKeyboardRequestCompletionHandler
protocol methods. Type Optional.
Method sendKeyboardRequest(buttonID:messageCurrentChatID:completionHandler:)
Method used to send the selected item in the chatbot keyboard to the Rox.Chat service.
May throw errors of type AccessError
.
Parameter buttonID
- ID of the item in the chatbot keyboard. The type is String
.
Parameter messageCurrentChatID
- ID of the requested message. Type - Message
.
Parameter completionHandler
- object implementing methods of protocol SendKeyboardRequestCompletionHandler
. Type Optional.
Method reply(message:repliedMessage:)
The method is used to quote a visitor's message to the Rox.Chat service.
It can throw errors of type AccessError
.
The message
parameter is the message to be sent. The type is String
.
Parameter repliedMessage
- quoted message. The type is Message
.
Returns the message ID or nil
if the message cannot be quoted.
Does not require any other methods to be called beforehand. If MessageTracker
and MessageListener
objects exist, sending a message will call the added(message:after:)
method of the MessageListener
interface with a new message with status MessageSendStatus.sent
.
The maximum message length is 32000 characters. Messages longer than this will be truncated.
Method edit(message:text:completionHandler:)
The method is used to modify the message.
May throw errors of type AccessError
.
The message
parameter is the message to be modified. The type is Message
.
Parameter text
- text of the message. Type - String
.
The completionHandler
parameter is an object that implements the EditMessageCompletionHandler
protocol methods. Type Optional.
Returns true
if the message can be edited.
Does not require any other methods to be called beforehand. If MessageTracker
and MessageListener
objects exist, sending a message will invoke the changed(oldVersion:newVersion:)
method of the MessageListener
interface with a new message with status MessageSendStatus.sent
.
The maximum message length is 32000 characters. Messages longer than that will be truncated.
Method delete(message:completionHandler:)
Method to delete a message.
Can throw errors like AccessError
.
The message
parameter is the message to be deleted. The type is Message
.
The completionHandler
parameter is an object that implements protocol methods DeleteMessageCompletionHandler
. Type Optional.
Returns true
if the message can be deleted.
Does not require any other methods to be called beforehand. If MessageTracker
and MessageListener
objects exist, sending a message will call the removed(message:)
method of the MessageListener
interface with a new message with status MessageSendStatus.sent
.
The maximum message length is 32000 characters. Messages longer than this will be truncated.
Method setChatRead()
Method sends a signal to the Rox.Chat service that the visitor has read the chat.
Method sendDialogTo(emailAddress:completionHandler:)
Method used to send the current dialog to an email address.
It may throw errors like AccessError
.
Parameter emailAddress
- email to send. The type is String
.
Parameter completionHandler
- object that implements protocol methods SendDialogToEmailAddressCompletionHandler
. Type Optional.
Method getVisitSessionState()
Returns the current session state with a value of type VisitSessionState
.
Method getChatState()
Method with which to specify the state of the current chat.
Returns a value of enumerated type ChatState
.
Method getUnreadByOperatorTimestamp()
Returns the point in time (of type Date
) after which all chat messages are unread by the operator (at the time of the update received from the server).
Method getUnreadByVisitorMessageCount()
Returns the number of unread messages by the user.
Method getUnreadByVisitorTimestamp()
Returns the point in time (of type Date
) after which all chat messages are unread by the visitor (at the time of the update received from the server) or nil
if there are no unread messages.
Method getDepartmentList()
Returns the department list by an array of objects of type Department
or nil
if departments are not in use or the department list has not yet been retrieved.
Method getLocationSettings()
Each location can have individual settings. Use the current method to get an object representing the current location settings.
Returns an object of class LocationSettings
corresponding to the current session.
Method getCurrentOperator()
Use this method to specify information about the current operator (if any) of the current chat session.
Returns an object of class Operator
or nil
if the chat does not currently have an operator.
Method getLastRatingOfOperatorWith(id:)
Use this method to specify the current rating (in integers from 0 to 5) of an operator, knowing the ID of that operator (see the getID()
method of the Operator
protocol).
The id
parameter is the ID of the operator whose rating the method should return. The type is String
.
Returns the rating of the operator with the ID corresponding to the value of the id
parameter, in integers from 1 to 5 or 0 if the operator has no rating.
Method rateOperatorWith(id:rating:completionHandler:)
Use this method to send the operator rating of the current visitor.
The id
parameter is the ID of the operator whose rating should be sent to the Rox.Chat service. The type is String
. Optional: if you pass nil
, the evaluation will be sent to the current chat operator (if any).
The rating
parameter is the operator's rating to be sent to the Rox.Chat service. The rating must be an integer from 1 to 5 (if you specify otherwise, the method will not perform any actions). The type is Int
.
The completionHandler
parameter is a RateOperatorCompletionHandler
object.
Can throw errors like AccessError
.
Warning!
Implementation of the operator evaluation mechanism is left to the developers of the mobile application!
Method startChat()
The method starts a chat. In terms of Rox.Chat service it changes the current chat state, represented by ChatState
type, to QUEUE
.
Can throw errors of type AccessError
.
When a user sends a message or file, the chat starts automatically, so calling the method is optional. But, if the account settings provide for welcome messages, no welcome messages will be received before the chat starts (by methods in the startChat
series or with the first message).
As a result, the method changed(state previousState:to newState:)
protocol ChatStateListener
may be called.
Method startChat(departmentKey:)
Method starts a chat by specifying a particular department. In terms of Rox.Chat service, changes the current chat state, represented by the type ChatState
, to QUEUE
.
Can throw errors of type AccessError
.
When a message or file is sent by a user, chat starts automatically, but if the current state is VisitSessionState
DEPARTMENT_SELECTION
, chat should be started using this method.
When a user sends a message or file, the chat starts automatically, so calling this method is not necessary.
If the account settings provide for welcome messages, no welcome messages will be received before the chat starts (using the startChat
series methods or with the first message).
The departmentKey
parameter is passed the value of the department key, which can be obtained by the getKey()
method of the Department
protocol.
As a result, the changed(state previousState:to newState:)
method of the ChatStateListener
protocol may be called.
Method startChat(firstQuestion:)
Method starts a chat and simultaneously sends the visitor's first message.
In terms of the Rox.Chat service, changes the current chat state, represented by the type ChatState
, to QUEUE
.
Can throw errors of type AccessError
.
When a user sends a message or file, the chat starts automatically, so calling the method is optional. But, if the account settings provide for welcome messages, no welcome messages will be received before the chat starts (by methods in the startChat
series or with the first message).
As a result, the changed(state previousState:to newState:)
protocol ChatStateListener
method may be called.
Method startChat(departmentKey:firstQuestion:)
The method starts a chat by specifying a particular department and simultaneously sends the visitor's first message.
In terms of the Rox.Chat service, changes the current chat state, represented by the type ChatState
, to QUEUE
.
Can throw errors of type AccessError
.
When a user sends a message or file, chat starts automatically, but if the current state is VisitSessionState
DEPARTMENT_SELECTION
, chat should be started using this method.
If the account settings provide for welcome messages, no welcome messages will be received before the chat is started (by the startChat
series methods or with the first message).
The departmentKey
parameter is passed the value of the department key, which can be obtained by the getKey()
method of the Department
protocol.
As a result, the method changed(state previousState:to newState:)
protocol ChatStateListener
may be called.
Method closeChat() (@available(*, deprecated))
N.B.
The method is not recommended for use.
The method sends a signal to the Rox.Chat service that the visitor has finished chatting. In terms of Rox.Chat service it changes the current chat state, represented by ChatState
type, to CLOSED_BY_VISITOR
.
May throw errors like AccessError
.
May result in a call to the changed(state previousState:to newState:)
method of the ChatStateListener
protocol.
Method setVisitorTyping(draftMessage:)
The method is used to send a signal to the Rox.Chat service that a visitor is typing a message (or has stopped typing it (the message)).
If the method is called multiple times consecutively, the draft is sent to the Rox.Chat service not with the same frequency, but not more often than once per second.
Parameter draftMessage
- the message that the visitor has already entered in the corresponding field, but has not sent it. Type - optional String
, The value of the parameter nil
corresponds to the situation when the visitor has stopped entering the message or erased the written message from the input field.
May throw errors of type AccessError
.
Method send(message:isHintQuestion:)
The method is used to send a visitor's message to the Rox.Chat service.
The message
parameter is the message to be sent. The type is String
.
Maximum length of the message is 32000 characters. Longer messages will be cut off by the server when they are received.
The isHintQuestion
parameter is used if the application has its own mechanism of showing hints to the user. The type is optional Bool
. In case the visitor does not enter a message manually, but chooses one of the offered prompts, the value of the parameter should be true
, and false
otherwise. The parameter is optional and may be omitted.
Returns a randomly generated ID for this message, which can be used to identify this particular message within the application logic. The type is String
.
Can throw errors of type AccessError
.
If MessageTracker
and MessageListener
objects exist, sending a message will invoke the method added(newMessage:previousMessage: )
protocol MessageListener
with a new message with status SENDING
of enumerated type MessageSendStatus
.
Method send(message:)
Fully corresponds to the method send(message:isHintQuestion:)
with the omitted parameter isHintQuestion
.
Method send(file:filename:mimeType:completionHandler:)
The method is used to send a file from the visitor to the operator.
The file
parameter is the file itself in Data
format.
The filename
parameter is the name of the file along with the extension. The type is String
.
Parameter mimeType
- MIME type of the file to be transferred. The type is String
.
The completionHandler
parameter is an object that implements the SendFileCompletionHandler
protocol methods. The type is optional.
Returns a randomly generated ID for this message, which can be used to identify this particular message within the application logic. (The file being sent is also a message type.) The type is String
.
Can throw errors of type AccessError
.
If MessageTracker
and MessageListener
objects exist, sending a message will call the method added(newMessage:previousMessage: )
protocol MessageListener
with a new message with status SENDING
of enumerated type MessageSendStatus
.
Method newMessageTracker(messageListener:)
This method is used to get an instance of MessageTracker
class.
The messageListener
parameter is an object of the class that implements the MessageListener
protocol methods.
Returns an instance of the MessageTracker
class corresponding to the current MessageStream
object.
May throw errors of type AccessError
.
Getting a new instance of class MessageTracker
automatically destroys the previous instance of class MessageTracker
.
Method set(visitSessionStateListener:)
The method passes to the SDK a reference to an object that implements the VisitSessionStateListener
protocol methods.
The chatStateListener
parameter is an object that implements the VisitSessionStateListener
protocol methods.
Method set(chatStateListener:)
The method passes to the SDK a reference to an object that implements the ChatStateListener
protocol methods.
The chatStateListener
parameter is an object that implements the ChatStateListener
protocol methods.
Method set(currentOperatorChangeListener:)
The method passes a reference to an object that implements the CurrentOperatorChangeListener
protocol methods to the SDK.
The currentOperatorChangeListener
parameter is an object implementing the CurrentOperatorChangeListener
protocol methods.
Method set(departmentListChangeListener:)
The method passes a reference to an object implementing the DepartmentListChangeListener
protocol methods to the SDK.
The currentOperatorChangeListener parameter is an object that implements the DepartmentListChangeListener
protocol methods.
Method set(operatorTypingListener:)
The method passes to the SDK a reference to an object that implements the OperatorTypingListener
protocol methods.
The operatorTypingListener
parameter is an object that implements the OperatorTypingListener
protocol methods.
Method set(locationSettingsChangeListener:)
The method passes to the SDK a reference to an object that implements the LocationSettingsChangeListener
protocol methods.
The locationSettingsChangeListener
parameter is an object that implements the locationSettingsChangeListener
protocol methods.
Method set(onlineStatusChangeListener:)
The method passes to the SDK a reference to an object that implements the sessionOnlineStatusChangeListener
protocol methods.
The sessionOnlineStatusChangeListener
parameter is an object that implements the SessionOnlineStatusChangeListener
protocol methods.
Method set(unreadByOperatorTimestampChangeListener:)
Passes the UnreadByOperatorTimestampChangeListener
object.
Method set(unreadByVisitorMessageCountChangeListener:)
Passes the UnreadByVisitorTimestampMessageCountListener
object.
Method set(unreadByVisitorTimestampChangeListener:)
Passes the UnreadByVisitorTimestampChangeListener
object.
Method getRawConfig(forLocation:completionHandler:)
Method used to get the configuration for a location.
It may throw errors of type AccessError
.
The forLocation
parameter is the name of the current location. The type is String
.
The completionHandler
parameter is an object that implements the RawLocationConfigCompletionHandler
protocol methods. Type Optional.
Method getServerSideSettings(completionHandler:)
Use this method to get the server settings.
The completionHandler
parameter is an object that implements the ServerSideSettingsCompletionHandler
protocol methods. The type is optional.
May throw errors of type AccessError
.
Method getChatId()
Use this method to get the id of the current chat.
Returns the id of the current chat or nil
if it does not exist. The type is optional Int
.
Protocol ServerSideSettingsCompletionHandler
An object implementing this protocol can be passed to the completionHandler
parameter of the getServerSideSettings(completionHandler:)
method of the MessageStream
protocol.
Method onSuccess(roxchatServerSideSettings:)
Called when the getServerSideSettings(completionHandler:)
method of the MessageStream
protocol succeeds.
The roxchatServerSideSettings
parameter is the server settings. Type RoxchatServerSideSettings
.
Method onFailure()
Called when the getServerSideSettings(completionHandler:)
method of the MessageStream
protocol fails.
Protocol DataMessageCompletionHandler
A protocol-object can be passed in the completionHandler
parameter of the send(message:data:completionHandler:)
method of the MessageStream
protocol.
Method onSuccess(messageID:)
The method is called when the message is successfully sent and the server processes the transmitted data
dictionary (if not nil
) using the send(message:data:completionHandler:)
method of the MessageStream
protocol.
The messageid
parameter is the ID of the corresponding message. The type is String
.
Method onFailure(messageID:error:)
Called when the server fails to process the transmitted data
dictionary (if not nil
) by the send(message:data:completionHandler:)
method of the MessageStream
protocol. The message itself will be processed by the server in this case.
The messageid
parameter is the ID of the corresponding message. The type is String
.
Parameter error
- the error that prevented the successful sending of the file. Type - DataMessageError
.
Protocol DeleteMessageCompletionHandler
A protocol-object can be passed in the completionHandler
parameter of the send(message:data:completionHandler:)
method of the MessageStream
protocol.
Method onSuccess(messageID:)
Called when the call to the delete(message:completionHandler:)
method of the MessageStream
protocol succeeds.
The messageid
parameter is the ID of the corresponding message. The type is String
.
Method onFailure(messageID:error:)
Called when the call to the delete(message:completionHandler:)
method of the MessageStream
protocol fails.
The messageid
parameter is the ID of the corresponding message. The type is String
.
The error
parameter - the error that prevented successful message deletion. Type - DeleteMessageError
.
Protocol RawLocationConfigCompletionHandler
A protocol object can be passed in the completionHandler
parameter of the getRawConfig(forLocation:completionHandler:)
method of the MessageStream
protocol.
Method onSuccess(rawLocationConfig:)
The method is called on successful request by the getRawConfig(forLocation:completionHandler:)
method of the MessageStream
protocol.
The rawLocationConfig
parameter is the location configuration. The type is [String: Any?]
.
Method onFailure()
Called when the getRawConfig(forLocation:completionHandler:)
method request fails.
Protocol SearchMessagesCompletionHandler
A protocol-subordinate object can be passed in the completionHandler
parameter of the searchStreamMessagesBy(query:completionHandler:)
method of the MessageStream
protocol.
Method onSearchMessageSuccess(query:messages:)
The method is called when a history query is successful using the searchStreamMessagesBy(query:completionHandler:)
method of the MessageStream
protocol.
The query
parameter is a query. The type is String
.
Parameter messages
- messages by request. The type is [String]
.
Method onSearchMessageFailure(query:)
Called when a history query fails using the searchStreamMessagesBy(query:completionHandler:)
method of the MessageStream
protocol.
The query
parameter is a query. The type is String
.
Protocol SendDialogToEmailAddressCompletionHandler
An object implementing this protocol can be passed to the completionHandler
parameter of the sendDialogTo(emailAddress:completionHandler:)
method of the MessageStream
protocol.
Method onSuccess()
Called when the call to the sendDialogTo(emailAddress:completionHandler:)
method of the MessageStream
protocol succeeds.
Method onFailure(error:)
Called when the call to the sendDialogTo(emailAddress:completionHandler:)
method of the MessageStream
protocol fails.
The error
parameter is the error that prevented the method from being called successfully. Type - SendDialogToEmailAddressError
.
Enumerated type SendDialogToEmailAddressError
Possible errors that can be passed to the error
parameter when calling the SendDialogToEmailAddressCompletionHandler.onFailure(error:)
method.
Case NO_CHAT
The chat does not exist.
Case SENT_TOO_MANY_TIMES
The send attempt limit has been exceeded.
Case UNKNOWN
Unknown error.
Protocol SendFileCompletionHandler
A protocol-object can be passed in the completionHandler
parameter of the send(file:filename:mimeType:completionHandler:)
method of the MessageStream
protocol.
Method onSuccess(messageID:)
The method is called when a file is successfully sent using the send(file:filename:mimeType:completionHandler:)
method of the MessageStream
protocol.
The messageid
parameter is the ID of the corresponding message. The type is String
.
Method onFailure(messageID:error:)
Called when sending a file fails using the send(file:filename:mimeType:completionHandler:)
method of the MessageStream
protocol.
The messageid
parameter is the ID of the corresponding message. The type is String
.
The error
parameter - the error that prevented the successful sending of the file. The type is SendFileError
.
Protocol SendKeyboardRequestCompletionHandler
An object implementing this protocol can be passed to the completionHandler
parameter of the sendKeyboardRequest
method of the MessageStream
protocol.
Method onSuccess(messageID:)
Called when the call to the sendKeyboardRequest
method of the MessageStream
protocol succeeds.
The messageid
parameter is the ID of the corresponding message. The type is String
.
Method onFailure(messageID:error:)
Called when the call to the sendKeyboardRequest
method of the MessageStream
protocol fails.
The messageid
parameter is the ID of the corresponding message. The type is String
.
The error
parameter - the error that prevented the method from being called successfully. Type - KeyboardResponseError.
Protocol SendMessageCompletionHandler
An object implementing this protocol can be passed to the completionHandler
parameter of the send(message:completionHandler:)
method of the MessageStream
protocol.
Method onSuccess(messageID:)
Called when the call to the send(message:completionHandler:)
method of the MessageStream
protocol succeeds.
The messageid
parameter is the ID of the corresponding message. The type is String
.
Protocol RateOperatorCompletionHandler
A protocol obeying object can be passed in the completionHandler
parameter of the rateOperatorWith(id:rating:completionHandler:)
method of the MessageStream
protocol.
Method onSuccess()
The method is called when the call to the rateOperatorWith(id:rating:completionHandler:)
method of the MessageStream
protocol succeeds.
Method onFailure(error:)
The method is called when the rateOperatorWith(id:rating:completionHandler:)
method of the MessageStream
protocol fails.
The error
parameter is the error that occurred. Type - RateOperatorError
.
Protocol visitSessionStateListener
A protocol whose adaptation allows you to track changes to visitSessionState
.
Method changed(state:to:)
The method is called when VisitSessionState
changes.
The old and new values are passed to the method parameters.
Protocol DepartmentListChangeListListener
A protocol whose adaptation allows tracking changes to the department list.
Method received(departmentList:)
The method is called when a new department list is received.
An array of Department
objects is passed to the method parameter.
Protocol LocationSettings
An instance of a class obeying the protocol can be retrieved using the getLocationSettings()
method of the MessageStream
object. Specific settings for the current location can be retrieved using the methods of this protocol.
Method areHintsEnabled()
With this method, retrieves whether the current location's settings mandate that hints be shown to the visitor when typing a new message.
Returns true
if hints should be shown, and false
otherwise. Type is Bool
.
Protocol ChatStateListener
A protocol whose methods are implemented by some application class. An object obeying the protocol can be passed in the chatStateListener
parameter of the set(chatStateListener:)
method of the MessageStream
protocol. Used to track changes to the current chat state.
Method changed(state previousState:to newState:)
The method is called when the state of the current chat has changed.
The previousState
parameter is the previous state of the chat. The type is ChatState
.
The newState
parameter is the new chat state. Type - ChatState
.
Protocol CurrentOperatorChangeListener
A protocol whose methods are implemented by some application class. An object obeying the protocol can be passed in the currentOperatorChangeListener parameter of the set(currentOperatorChangeListener:)
method of the MessageStream
protocol.Used to track changes to the current chat operator.
Method changed(operator previousOperator:to newOperator:)
The method is called when the current chat operator has changed (or the operator is gone).
The previousOperator
parameter is the previous operator. The type is Operator
.
Parameter newOperator
- new chat state. Type - optional Operator
. Takes the value nil
if the operator has left the chat.
Protocol OperatorTypingListener
A protocol obeying object can be passed in the operatorTypingListener
parameter of the set(operatorTypingListener:)
method of the MessageStream
protocol.Used to alert you when an operator starts typing a message.
Method onOperatorTypingStateChanged(isTyping:)
The method is called when the current chat operator has started typing a message.
The isTyping
parameter is true
if the operator is typing a message, and false
otherwise. The type is Bool
.
Protocol LocationSettingsChangeListener
A protocol whose methods are implemented by some class of the mobile application. An object of the class that obeys the protocol can be passed in the locationSettingsChangeListener
parameter of the set(locationSettingsChangeListener:)
method of the MessageStream
protocol. Used to track changes to the current location settings.
Method changed(locationSettings previousLocationSettings:to newLocationSettings:)
The method is called when the current location settings have changed.
The previousLocationSettings
parameter is the previous value of the current location settings. The type is LocationSettings
.
Parameter newLocationSettings
- new value of the current location settings. Type - LocationSettings
.
Protocol OnlineStatusChangeListener
The protocol is adapted by entities of the mobile application. The object of the class that adapted the protocol can be passed in the sessionOnlineStatusChangeListener
parameter of the set(onlineStatusChangeListener:)
method of the MessageStream
protocol. Used to receive notifications when the session status changes. The session status is described in values of enumerated type OnlineStatus
.
Method changed(onlineStatus previousOnlineStatus:to newOnlineStatus:)
The method is called when the session status changes.
The previousSessionOnlineStatus
parameter is the previous session status. The type is OnlineStatus
.
Parameter newSessionOnlineStatus
- new (received) session status. Type - OnlineStatus
.
The method is called as a result of received notification from Rox.Chat service.
Protocol UnreadByOperatorTimestampChangeListener
A protocol that provides methods for handling changes to the parameter returned by the getUnreadByOperatorTimestamp()
method. The protocol-adapting object is passed using the set(unreadByOperatorTimestampChangeListener:)
method.
Method changedUnreadByOperatorTimestampTo(newValue:)
A method that is called when the parameter returned by the getUnreadByOperatorTimestamp()
method changes.
The newValue
parameter is the new value returned by the getUnreadByOperatorTimestamp()
method. The type is optional Date
.
Protocol UnreadByVisitorMessageCountChangeListener
A protocol that provides methods to handle changes to the parameter returned by the getUnreadByVisitorMessageCount()
method.The object adapting the protocol is passed using the set(unreadByVisitorMessageCountChangeListener:)
method.
N.B.
The class object that implements this protocol can only be retrieved after the session starts using the resume()
method. This object increments the value of the number of unread messages by sending appropriate requests to the server every 30 seconds.
Method changedUnreadByVisitorMessageCountTo(newValue:)
A method that is called when the parameter returned by the getUnreadByVisitorMessageCount()
method changes.
The newValue
parameter is the new value returned by the getUnreadByVisitorMessageCount()
method. The type is Int
.
Protocol UnreadByVisitorTimestampChangeListener
A protocol that provides methods for handling changes to the parameter returned by the getUnreadByVisitorTimestamp()
method. The protocol-adapting object is passed using the set(unreadByVisitorTimestampChangeListener:)
method.
Method changedUnreadByVisitorTimestampTo(newValue:)
A method that is called when the parameter returned by the getUnreadByVisitorTimestamp()
method changes.
The newValue
parameter is the new value returned by the getUnreadByVisitorTimestamp()
method. The type is optional Date
.
Protocol UploadedFile
Contains methods that can be used to get information about a file.
Method getSize()
A method by which the size of an attachment file can be obtained.
Returns the size of the attachment file in bytes. The type is Int64
.
Method getGuid()
A method by which the guid
of the attachment file can be obtained.
Returns the value in text form. The type is String
.
Method getFileName()
A method that can be used to get the name of the attachment file.
Returns the name of the attachment file in text form. The type is String
.
Method getContentType()
A method by which the MIME type of the attachment can be obtained.
Returns the MIME type of the attachment in text form. The type is an optional String
.
Method getVisitorId()
A method that can be used to get the id of the file sender.
Returns the value in text form. The type is String
.
Method getClientContentType()
A method by which the MIME type of an attachment can be obtained.
Returns the MIME type of the attachment in text form. The type is String
.
Method getImageInfo()
A method that can be used to get information about an image.
Returns information about the image. The type is optional ImageInfo
.
Enumerated type ChatState
Possible chat state options (see the getChatState()
method of the MessageStream
protocol). The initial state is NONE
. If the startChat()
method or one of the MessageStream
protocol's message sending methods is called, the state changes to QUEUE
. When an operator accepts a chat into processing, its (chat) state is changed to CHATTING
. When the closeChat()
method of the MessageStream
protocol is called, the chat state is changed to CLOSED_BY_VISITOR
. If the chat was closed by an operator - to CLOSED_BY_OPERATOR
. After the chat has been closed by both the visitor and the operator, its state returns to NONE
. This also happens after a long time of no activity in the chat. The chat can also be restarted by the operator: in this case the chat state takes the value INVITATION
, and after the visitor writes something back, the chat state takes the value CHATTING
.
Case CHATTING
The chat state when either the operator has taken a visitor-initiated chat into processing, or when a visitor has responded to a message in a previously closed chat.
From this state, the chat can transition to either CLOSED_BY_OPERATOR
, CLOSED_BY_VISITOR
, or NONE
.
Case of CHATTING_WITH_ROBOT
The chatting state when either bot has responded in a visitor-initiated chat.
From this state, the chat can go to either CHATTING
, CLOSED_BY_VISITOR
, or NONE
.
Case CLOSED_BY_OPERATOR
The state of a chat when it has been closed by an operator, but not yet closed by a visitor.
From this state, the chat can go to either NONE
or QUEUE
if the visitor writes something else.
Case CLOSED_BY_VISITOR
The state of the chat when it has been closed by the visitor, but not yet closed by the operator.
From this state, the chat can go to either NONE
or QUEUE
if the visitor writes something else.
Case INVITATION
The state of the chat when it was initiated by the operator.
From this state, the chat can go to either NONE
or CHATTING
.
Case NONE
Denotes the absence of chatting.
From this state, the chat can go to either INVITATION
or QUEUE
.
Case QUEUE
The state of the chat when it was initiated by a visitor.
From this state, the chat can go to either NONE
, CHATTING
, or CLOSED_BY_OPERATOR
.
Case UNKNOWN
This state is received by chatting when a session is created, before the first chatting state update received from the server.
Also, this state can be received if the SDK cannot identify it (for example, the server has new chat state values that the current version of the SDK does not know how to handle).
Enumerated type OnlineStatus
Possible online statuses.Can be retrieved using the changed(onlineStatus previousOnlineStatus:to newOnlineStatus:)
protocol SessionOnlineStatusChangeListener
method.
Case BUSY_OFFLINE
Offline state with the number of chat limits exceeded.
Means that the visitor cannot send messages at all.
Case BUSY_ONLINE
An online state with the number of chat limits exceeded.
Means that the visitor can send messages to the offline area, but the server may reject them and return an error.
Case OFFLINE
Means that the visitor can send messages to the offline zone.
Case ONLINE
Means that the visitor can send messages without any restrictions.
Case UNKNOWN
Indicates that either the SDK has not yet received the first session status update from the Rox.Chat service, or the session status is not supported in the current version of the SDK.
Enumerated type VisitSessionState
Possible session statuses.
Case CHAT
The status of the chat session.
Case DEPARTMENT_SELECTION
Indicates that an attempt was made to start a chat without department selection, and the server is set to make department selection mandatory.
The session expects to start a chat using the startChat(departmentKey:)
method.
Case IDLE
The session is active, but chat has not been started yet.
Case IDLE_AFTER_CHAT
The session is active, but the chat has already been closed.
Case OFFLINE_MESSAGE
Offline.
Case UNKNOWN
Status has not yet been received or is not supported by the current version of RoxchatClientLibrary
.
Enumerated type SendFileError
Possible errors that can be passed to the error
parameter of the onFailure(messageID:error:)
method of the SendFileCompletionHandler
protocol.
Case FILE_SIZE_EXCEEDED
Indicates that the file size exceeds the maximum size set in the server settings.
Case FILE_TYPE_NOT_ALLOWED
Indicates that the file type is not among the allowed types set in the server settings.
Case UPLOADED_FILE_NOT_FOUND
Indicates that the file was transferred in the wrong way.
Case UPLOAD_CANCELED
Indicates that the file upload was canceled due to a deactivated session or other reasons.
Case UNKNOWN
Unknown error.
Case UNAUTHORIZED
Unknown error.
Enumerated type RateOperatorError
.
Possible errors that can be passed to the error
parameter of the onFailure(error:)
method of the RateOperatorCompletionHandler
protocol.
Case NO_CHAT
Occurs when attempting to send an operator evaluation when no chat exists.
Case WRONG_OPERATOR_ID
Occurs when an operator ID that does not belong to the current chat was passed in an attempt to send an operator evaluation.
Case NOTE_IS_TOO_LONG
The comment is too long. The maximum length is 2000 characters.
Protocol MessageTracker
An instance of a class that obeys the protocol can be retrieved using the new(messageTracker:)
method of the MessageStream
protocol. Protocol methods are used to manipulate messages that exist in the message history.
Method getLastMessages(byLimit:completion:)
The method is used to request messages from the beginning of the message history.
The limitOfMessages
parameter is the number of next messages, no more than which the method should request. The type is Int
, the value can be any positive greater than 1 (if a value less than 1 is passed, the method will not do any work).
The completion
parameter is a closure that is executed after the method completes execution. The closure contains one parameter of type array Message
and has no return type. Typically, the expected set of messages from the message history is passed to the parameter. If the parameter does not contain any object of type Message
(the array is empty) - it means that the end of the message history has been reached. If the method did not throw any error during execution, the passed closure is guaranteed to be executed (with empty or not result).
Each subsequent call to this method can only be made after the previous request has been completed (the closure has been called).
May throw errors of type AccessError
.
The method will not do any work if the corresponding object MessageTracker
has been deactivated (see method destroy()
).
The method may return the number of messages less than the limit, but this will not mean that there are no more messages left. In such a situation, the method can be reused to further unload messages. If there are no messages left, the method will return null.
Method getNextMessages(byLimit:completion:)
The method is used to request messages from the message history that are not yet displayed in the current message feed.
The limitOfMessages
parameter is the number of next messages, no more than the method should request. The type is Int
, the value can be any positive greater than 1 (if a value less than 1 is passed, the method will not do any work).
The completion
parameter is a closure that is executed after the method completes execution. The closure contains one parameter of type array Message
and has no return type. Typically, the expected set of messages from the message history is passed to the parameter. If the parameter does not contain any object of type Message
(the array is empty) - it means that the end of the message history has been reached. If the method did not throw any error during execution, the passed closure is guaranteed to be executed (with empty or not result).
Each subsequent call to this method can only be made after the previous request has been completed (the closure has been called).
May throw errors of type AccessError
.
The method will not do any work if the corresponding MessageTracker
object has been deactivated (see destroy()
method).
Method getAllMessages(completion:)
The method is used to query the entire message history at once.
The completion
parameter is a closure that is executed after the method completes. The closure contains one parameter of type array Message
and has no return type. Typically, the expected set of messages from the message history is passed to the parameter. If the parameter does not contain any object of type Message
(the array is empty) - it means that the end of the message history has been reached. If the method did not throw any error during execution, the passed closure is guaranteed to be executed (with empty or not result).
May throw errors of type AccessError
.
The method will not do any work if the corresponding MessageTracker
object has been deactivated (see destroy()
method).
Method resetTo(message:)
The MessageTracker
object stores the current range of messages. A call to this method can "reset" the limit to which the object stores message history to a particular message.
The message
parameter is the message to which the limit of the stored message history should be "reset". The type is Message
.
Can throw errors of type AccessError
.
The method can only be called after a previous call to the MessageTracker
object has returned a result, otherwise the method will not do any work.
Method destroy()
Deactivates the current MessageTracker
object, after which no protocol methods can be used.
May throw errors like AccessError
.
Protocol MessageListener
The protocol must be adapted by some application class. The protocol methods are called when changes are made to the message feed.
Method added(newMessage:previousMessage:)
The method is called when messages are added to the current feed. Importantly, calling the method is not an indication that a new message has been received: it is a logical insertion of messages into the feed. For example, on the first successful connection to the server, the SDK retrieves the entire message history. If it contains messages that are in the time frame already displayed in the feed, this method will also be called on each such message.
The newMessage
parameter is the message received. The type is Message
.
Parameter previousMessage
- the message after which the received message should be inserted. Type - optional Message
. If the value of this parameter is nil
, the received message should be inserted at the end of the list.
Method removed(message:)
The method is called when a message is removed from the feed.
The message
parameter is the deleted message. The type is Message
.
Method removedAllMessages()
The method is called when all messages are removed from the feed.
Method changed(oldVersion:newVersion:)
The method is called when any message is changed.
Messages as such are not changed: one object is replaced by another. Therefore, when this method is called, you can compare the message fields to find out which ones are different.
The oldVersion
parameter is the former object of the message. The type is Message
.
The newVersion
parameter is the new message object. The type is Message
.
Protocol Message
A protocol is an abstraction representing a single message within the SDK. Message
objects can be retrieved in calls to the protocol's MessageListener
methods.
The Message
objects are immutable. Changes to any of its fields creates a new object. Two Message
objects can be checked for identical fields using the isEqual(to:)
method. Logical correspondence of message objects can be checked by comparing their IDs (see the getID()
method).
Method getRawData()
Use this method to get an arbitrary dictionary generated by the server when MessageType
ACTION_REQUEST
is used.
Returns a dictionary of type [String: Any?]
or nil
if none exists.
Method getData()
Messages of type FILE_FROM_OPERATOR
or FILE_FROM_VISITOR
may contain nested files. Use this method to retrieve the file.
Returns an instance of class MessageData
or nil
if the file is in the process of being sent.
Method getCurrentChatID()
Use this method to get the unique ID of the current chat.
It returns the ID of the chat room. The type is String
or nil
if the ID is missing.
Method getKeyboard()
Use this method to get the keyboard element of a chatbot.
Returns a keyboard with buttons. The type is optional Keyboard
.
Method getKeyboardRequest()
This method retrieves the keyboard element that the user has selected.
Returns the keyboard element selected by the user. The type is optional KeyboardRequest
.
Method getQuote()
Use this method to get information about the quoted message.
It returns the quoted message. The type is class optional Quote
.
Method isReadByOperator()
Use this method to get information about the status of a message. Whether it has been read by the operator or not.
Returns true
if the message is read by the operator and false
if it is not. The type is Bool
.
Method canBeEdited()
Use this method to get information about whether a message can be modified or deleted.
Returns true
if it can, and false
if it cannot. The type is Bool
.
For the method to return true
in principle, the functionality corresponding to the method (editing and deleting messages) must be active on the account. In this case, the value of the account config
parameter visitor_message_editing
must be true
. Otherwise, the method will always return false
.
Method canBeReplied()
Use this method to get information about whether the given message can be replied to.
Returns true
if it is possible and false
if it is not. The type is Bool
.
For the method to return true
in principle, the functionality corresponding to the method (message quoting) must be active on the account. In this case, the value of the account config
parameter web_and_mobile_quoting
must be true
. Otherwise, the method will always return false
.
Method getID()
Use this method to get the unique ID of a message.
It returns the ID of the message. The type is String
.
Method getOperatorID()
Use this method to get the ID of the operator that sent the message.
Returns the operator ID or nil
if the message was sent by a non-operator. The type is optional String
.
Method getSenderAvatarFullURL()
Use this method to get the URL to load the message sender's avatar (if any).
Returns the full URL of the message sender's avatar or nil
if there is no avatar. The type is an optional URL.
Method getSenderName()
Use this method to get the name of the message sender.
Returns the name of the message sender. The type is String
.
Method getSendStatus()
Use this method to get the send status of a message.
It returns a value of enumerated type MessageSendStatus
.
Method getText()
Use this method to get the text of a message.
It returns the text of the message. The type is String
.
Method getTime()
Use this method to get the time the message was sent.
Type - Date
.
Method getType()
Use this method to get the type of the message.
It returns the value of the enumerated type MessageType
.
Method isEqual(to message:)
Use this method to find out if two messages are identical.
Example usage:
if messageOne.isEqual(to: messageTwo) { /* .... */ }
Where messageOne
and messageTwo
are any instances of type Message
.
The message
parameter is the message to which the message on which the method is called is compared. The type is Message
.
Returns true if the message fields are identical, and false
if they are not. Type - Bool
.
Method isEdited()
Use this method to find out if a message has been edited or not.
Returns true
if the message has been modified and false
if not. The type is Bool
.
Protocol MessageAttachment
Protocol is an abstraction representing a file attachment to a message. A MessageAttachment
object can be retrieved using the getAttachment()
Message
method.
Method getFileInfo()
A method that can be used to get information about an attached file.
Returns information about the file. The type is FileInfo
.
Method getState()
A method to get the file upload status of a file to the server.
Returns information about the file upload status. The type is AttachmentState
.
Method getDownloadProgress()
A method to get the percentage of file download to the server.
Returns the download percentage of the file. The type is optional Int64
.
Method getErrorType()
A method to get the type of error that caused the file upload problems.
Returns the type of the error. The type is an optional String
.
Method getErrorMessage()
A method to get the error text of the error that caused the file upload problem.
Returns the text of the error. The type is optional String
.
Method getFilesInfo()
A method that can be used to get information about attached files.
Returns information about the files. The type is FileInfo
.
Protocol ImageInfo
Protocol is an abstraction representing information about an attachment if it is an image. An ImageInfo
object can be retrieved using the getImageInfo()
method of the MessageAttachment
protocol.
Method getThumbURL()
The method allows you to get the URL for downloading a preview of an image. The maximum vertical and horizontal dimensions are 300 pixels, but can be changed on the server. In order to know the exact size of the preview until the image is downloaded, you can use the following code:
let THUMB_SIZE = 300
var width = imageInfo.getWidth()
var height = imageInfo.getHeight()
if (height > width) {
width = (THUMB_SIZE * width) / height
height = THUMB_SIZE
} else {
height = (THUMB_SIZE * height) / width
width = THUMB_SIZE
}
Returns the URL to download a preview of the image. The resulting link is valid only for the current session.
Method getHeight()
A method that can be used to get the height of an image.
Returns the height of the image in pixels or nil
. The type is optional Int
.
Method getWidth()
A method that can be used to get the width of the image.
Returns the width of the image in pixels or nil
. The type is optional Int
.
Enumerated type MessageType
Used to define the message type (see the getType()
method of the Message
protocol).
Case ACTION_REQUEST
A message containing a dictionary of arbitrary data to be processed by the application based on client-defined logic (see the getData()
method of the Message
protocol).
Case CONTACTS_REQUEST
The message that arrives after the operator has pressed the contact request button. There is currently no automatic support for this functionality; any payload of this and the response message is forwarded in the message text (see the getText()
method of the Message
protocol).
Case FILE_FROM_OPERATOR
The file sent by the operator.
Case FILE_FROM_VISITOR
A file sent by a visitor.
Case INFO
A system message automatically generated on the server (for example, a greeting at the beginning of a chat).
Case KEYBOARD
A message sent by a chatbot.
Case KEYBOARD_RESPONSE
A message from the chatbot containing information about the button the user selected.
Case OPERATOR
A text message from the operator.
Case OPERATOR_BUSY
A system message indicating that the operator is currently busy.
Case VISITOR
A text message from a visitor.
Enumerated type MessageSendStatus
Used to determine the sending status of a message (see the getSendStatus()
method of the Message
protocol).
Case SENDING
Indicates any state of the message until it has been received, processed, and sent to all recipients by the server.
Case SENT
Indicates any state of the message after the events listed in the SENDING
value description.
Protocol Department
.
A representation of a single department. Provides methods for obtaining information about a department.Department
objects can be obtained by adapting the DepartmentListChangeListener
protocol or by calling the getDepartmentList()
method of the MessageStream
protocol.
Method getKey()
The department key is required to start a chat with a specific department method (startChat(departmentKey:)
method MessageStream
).
The return value type is String
.
Method getName()
Returns the public name of the department.
The return value type is String
.
Method getDepartmentOnlineStatus()
Returns the online status of a department.
The return value type is DepartmentOnlineStatus
.
Method getOrder()
Returns a number representing the order of the department's output in the list. A higher number indicates a higher priority to output the department in the list.
The return value type is Int
.
Method getLocalizedNames()
Returns a dictionary of localized department names, if one exists.
The return value type is the optional [String: String]
. The key is the locale name, the value is the locale-matching department name.
Method getLogoURL()
Returns the URL of the department logo (if any).
The return value type is an optional URL.
Enumerated type DepartmentOnlineStatus
Possible statuses of the department. Can be obtained by calling the getDepartmentOnlineStatus()
method of the Department
protocol.
Case BUSY_OFFLINE
Offline, chat limit exceeded.
Case BUSY_ONLINE
Online, chat limit exceeded.
Case OFFLINE
Visitor can send offline messages.
Case ONLINE
The visitor can send online messages.
Case UNKNOWN
The current status is not supported by this version of RoxchatClientLibrary
.
Enumerated type DeleteMessageError
Possible errors that can be passed to the error
parameter when calling the DeleteMessageCompletionHandler.onFailure(messageID:error:)
method.
Case UNKNOWN
Unknown error.
Case NOT_ALLOWED
The server has disabled the ability to delete messages.
Case MESSAGE_NOT_OWNED
A visitor can only delete their own messages. The specified identifier belongs to another message.\
case MESSAGE_NOT_FOUND
The selected message was not found.
Protocol Operator
A protocol object is an abstract representation of each concrete chat operator. Protocol Operator
objects can be obtained in the CurrentOperatorChangeListener
protocol methods and the getCurrentOperator()
protocol MessageStream
method.
Method getID()
The method allows you to get the ID of a specific operator.
Returns the ID of a specific operator. The type is String
.
Method getName()
The method allows you to get the name of a specific operator.
Returns the name of a specific operator. The type is String
.
Method getAvatarURL()
Method allows you to get the URL to download the avatar of a specific operator (if any).
Returns the URL to download a specific operator's avatar or nil
.
Method getTitle()
Method allows you to get the title of an employee.
Returns the title of the employee. The type is optional String
.
Protocol RoxchatRemoteNotification
A protocol object is an abstract representation of a specific push notification received by an application from the Rox.Chat service. RoxchatRemoteNotification
protocol objects can be retrieved using the parse(remoteNotification:)
method of the Roxchat
class.
Method getType()
Use this method to specify useful information of a particular RoxchatRemoteNotification
object.
Returns the value of the enumerated type NotificationType
.
Method getEvent()
Use this method to specify an intended action that involves receiving this particular object RoxchatRemoteNotification
.
Returns a value of enumerated type NotificationEvent
or nil
.
Method getParameters()
Use this method to specify the payload of a particular RoxchatRemoteNotification
object, depending on its type and contained in an array.
Returns an array of type String
. See the description of the enumerated type NotificationType
for possible array contents.
Method getLocation()
Method can be called to get the location of a chat room.
Returns an optional value of type String
.
Method getUnreadByVisitorMessagesCount()
The method can be called to get the number of unread messages by the user.
It returns the number of messages. The type is Int
.
Protocol RoxchatAlert
The protocol is designed to handle alerts (alerts).
Method present(title:message)
The method is used to show warnings about standard errors.
The title
parameter is the title of the warning, the type is String
.
The message
parameter is the content of the warning, type - String
.
Enumerated type NotificationType
Type values indicate the type of useful information comprising a particular push notification - can be retrieved using the getType()
method of the RoxchatRemoteNotification
protocol.
Case CONTACT_INFORMATION_REQUEST
Indicates an event where the operator sent a visitor a request for contact information.
The parameter dictionary (see the getParameters()
method of the RoxchatRemoteNotification
protocol) is empty in this case.
Case OPERATOR_ACCEPTED
Indicates the event when an operator has joined the chat room.
The parameter dictionary (see the getParameters()
method of the RoxchatRemoteNotification
protocol) contains only one value in this case, the operator name.
Case OPERATOR_FILE
Indicates the event when the operator sent a file to the chatroom.
The parameter dictionary (see the getParameters()
method of the RoxchatRemoteNotification
protocol) in this case contains two values - operator name and file name.
Case OPERATOR_MESSAGE
Indicates the event when an operator has sent a message to the chat room.
The parameter dictionary (see the getParameters()
method of the RoxchatRemoteNotification
protocol) contains two values in this case, the operator name and the message text.
Case WIDGET
Indicates an event when an operator sent a widget message (this functionality is not supported by default, you should contact support to support it).
The parameter dictionary (see the getParameters()
method of the RoxchatRemoteNotification
protocol) is empty in this case.
Case rateOperator
Indicates the event when the operator sent an operator rate request to the visitor.
The parameter dictionary (see the getParameters()
method of the RoxchatRemoteNotification
protocol) is empty in this case.
Enumerated type NotificationEvent
Indicates an event that implies the type of action expected of the application when receiving this particular push notification - can be obtained using the getEvent()
method of the RoxchatRemoteNotification
protocol.
Case ADD
Add the information contained in this push notification (see the getType()
and getParameters()
methods of the RoxchatRemoteNotification
protocol)).
Case DELETE
Deletes the information contained in this push notification (see the getType()
and getParameters()
methods of the RoxchatRemoteNotification
protocol)).
Protocol FatalErrorHandler
Protocol methods are called when necessary to handle errors that the Rox.Chat service may return during operation. See the enumerated type values FatalErrorType
for error descriptions
Method on(error:)
Called when an error is received by the Rox.Chat service. The protocol object RoxchatError
is passed in the parameter.
Warning!
The method is called not from the main thread!
Enumerated type FatalErrorType
Corresponds to the values of possible errors that may occur in the Rox.Chat service (see the getErrorType()
method of the RoxchatError
protocol). Most of these are fatal and cause the session object to be destroyed.
Case ACCOUNT_BLOCKED
Indicates that the client's account in the Rox.Chat service is blocked (for example, for non-payment).
The occurrence of the error does not depend on the visitor's actions, and the possible behavior of the application in case of this error is presented as a suggestion to the visitor to try to use the chat later.
Causes session destruction.
Case PROVIDED_VISITOR_FIELDS_EXPIRED
Indicates that the user data provided during session creation (see the set(visitorFieldsJSONString:)
and set(visitorFieldsJSONData:)
methods of the SessionBuilder
class) are no longer valid.
Proposed application behavior is to generate new user data and create a new session instance.
Causes the session to be destroyed.
Case UNKNOWN
Indicates the occurrence of some unexpected and undocumented error.
Causes the session to be destroyed.
Case VISITOR_BANNED
Occurs when a user with passed data (see methods set(visitorFieldsJSONString:)
and set(visitorFieldsJSONData:)
of class SessionBuilder
) has been blocked by the operator for any reason.
Causes the session to be destroyed.
Case WRONG_PROVIDED_VISITOR_HASH
Indicates an error in generating user data. Does not depend on user actions, but signals an error in the application's data generation algorithm.
Causes session destruction.
Protocol RoxchatError
RoxchatError
objects are passed to the error
parameter of the on(error:)
method of the protocol FatalErrorHandler
. The protocol methods are designed to handle fatal errors that may occur when working with the Rox.Chat service.
Method getErrorType()
The method is intended to obtain the specific type of error that occurred.
Returns a value of enumerated type FatalErrorType
.
Method getErrorString()
The method can be called to obtain a textual representation of the error that occurred.
Returns a textual representation of the error that occurred. Type - String
.
Protocol RoxchatNotFatalError
RoxchatNotFatalError
objects are passed to the error
parameter of the onError(error:)
method of the protocol NotFatalErrorHandler
.
Method getErrorType()
The method is intended to obtain the specific type of error that occurred.
Returns a value of type NotFatalErrorType
.
Method getErrorString()
The method can be called to obtain a textual representation of the error that occurred.
Returns a textual representation of the error that occurred. Type is String
.
Enumerated type AccessError
The type value corresponds to errors that can be thrown by some methods of the RoxchatSession
, MessageStream
and MessageTracker
protocols.
Case of INVALID_THREAD
Occurs when the method was called from a thread other than the one on which the session instance was created.
Case of INVALID_SESSION
Occurs when an attempt is made to use methods on an invalid session instance (for example, after the destroy()
method has been called on it).
Protocol RoxchatLogger
A protocol that provides methods for implementing "logging" of network activity RoxchatClientLibrary
. The mechanism can be useful, for example, when debugging product releases in which DEBUG
logs are not available.
Method log(entry:)
A method that is called automatically when a new entry is released for the RoxchatClientLibrary
network activity log.
The new entry is passed in the entry
parameter (type - String
).
Returned HTTP error codes
Category | Error code | Meaning and possible way to solve it |
---|---|---|
General errors | ||
account-blocked |
The client's account in the Rox.Chat service is blocked (for example, for non-payment). Contact Rox.Chat technical support for help. | |
chat-required |
Reply to an action in chat without chat | |
content_type_not_recognized |
The MIME type of the attachment is not recognized. Check to see if the file you are sending is damaged. Also make sure that its content matches one of the MIME types | |
domain-not-from-whitelist |
The domain is not whitelisted | |
max_file_size_exceeded |
The upload file size is too large. Try reducing the file size or increasing the weight limit for uploaded files | |
file_size_too_small |
The upload file size is too small. You may be trying to upload an empty file | |
not_allowed_file_type |
Uploading this file format is prohibited or not supported. Change the parameter responsible for file types allowed for uploading in the server settings | |
not_allowed_mime_type |
Uploading a file of this MIME type is prohibited or not supported. Change the parameter responsible for MIME file types allowed for uploading in the server settings | |
no_previous_chats |
Previous chats are missing | |
not_matching_magic_numbers |
Magic numbers don't match | |
max_files_count_per_chat_exceeded |
The maximum number of files sent in one chat has been reached | |
provided-visitor-expired |
The user data provided when creating the session is no longer valid. This error is resolved automatically by reinitialization | |
reinit-required |
Reinitialization is required - most likely, the AuthToken is outdated. This error is resolved automatically by reinitialization | |
setting_disabled |
Requested setting disabled | |
server-not-ready |
The server is not ready to respond to the request. This error appears when you try to contact the server before it is fully turned on. Try to wait a little | |
session_not_found |
The session you were looking for was not found | |
unathorized |
Unauthorized access attempt. Authorization required | |
uploaded-file-not-found |
Uploaded file not found | |
visitor_banned |
The visitor was blocked by the operator | |
wrong-argument-value |
The error occurs when a request arrives at the server with an incorrect argument type (for example, String instead of int) | |
wrong-provided-visitor-hash-value |
An error occurs when a visitor with an invalid signature tries to authorize | |
Errors in quoting messages in chat | ||
quoting-message-that-cannot-be-replied |
The message cannot be quoted - it is not marked with the canBeReplied flag or the flag is not set to true |
|
quoting-message-from-another-visitor |
The message ID sent corresponds to another visitor | |
corrupted-quoted-message-id |
Invalid quoted message ID | |
multiple-quoted-messages-found |
The message ID sent matches multiple messages (most likely there is a database error) | |
quoted-message-not-found |
The ID sent does not match any message in the database | |
required-quote-args-missing |
One or more server-side citation system arguments were not sent | |
Authentication errors | ||
provided-auth-token-not-found |
The authentication token was not found on the server. This error only occurs when using a custom client authentication mechanism via a token. Most likely, the token has not yet reached the Rox.Chat service from the client server and you need to wait a little | |
Errors related to sending, editing and deleting messages | ||
message_empty |
Attempting to send an empty message | |
max-message-length-exceeded |
Maximum allowed message length reached | |
message_not_found |
Message with the required ID was not found | |
not_allowed |
The ability to edit/delete messages is disabled on the server | |
message_not_owned |
The visitor is trying to edit/delete an operator's message or the specified ID belongs to another message | |
wrong_message_kind |
A visitor tries to edit a non-text message | |
Agent rate errors | ||
no-chat |
Occurs in the following cases:
|
|
operator-not-in-chat |
Occurs when trying to send an operator rating, the ID of an operator that does not belong to the current chat was sent | |
note-is-too-long |
Maximum comment length limit exceeded - 2000 characters | |
Keyboard response errors | ||
button-id-not-set |
Button ID not set | |
requset-message-id-not-set |
Request message ID not set | |
can-not-create-response |
Unable to create a response | |
Errors sending chats via email | ||
chat-history-sent-too-many-times |
Chat history has been sent too many times | |
File deletion errors | ||
file-has-been-sent |
The file is attached to the message and cannot be deleted | |
file-not-found |
File not found |