- Webim class
- SessionBuilder class
- Instance method set(accountName:)
- Instance method set(location:)
- Instance method set(appVersion:)
- Instance method set(visitorFieldsJSONString:)
- Instance method set(visitorFieldsJSONData:)
- Instance method set(providedAuthorizationTokenStateListener:providedAuthorizationToken:)
- Instance method set(pageTitle:)
- Instance method set(fatalErrorHandler:)
- Instance method set(remoteNotificationSystem:)
- Instance method set(deviceToken:)
- Instance method set(isLocalHistoryStoragingEnabled:)
- Instance method set(isVisitorDataClearingEnabled:)
- Instance method set(webimLogger:verbosityLevel:)
- Instance method build()
- WebimLoggerVerbosityLevel enum
- SessionBuilderError enum
- ProvidedAuthorizationTokenStateListener protocol
- WebimSession protocol
- MessageStream protocol
- getVisitSessionState() method
- getChatState() method
- getUnreadByOperatorTimestamp() method
- getUnreadByVisitorMessageCount() method
- getUnreadByVisitorTimestamp() method
- getDepartmentList() method
- getLocationSettings() method
- getCurrentOperator() method
- getLastRatingOfOperatorWith(id:) method
- rateOperatorWith(id:byRating:completionHandler:) method
- startChat() method
- startChat(firstQuestion:) method
- startChat(departmentKey:) method
- startChat(departmentKey:firstQuestion:) method
- closeChat() method
- send(message:) method
- setVisitorTyping(draftMessage:) method
- send(message:data:completionHandler:) method
- send(message:isHintQuestion:) method
- send(file:filename:mimeType:completionHandler:) method
- newMessageTracker(messageListener:) method
- set(visitSessionStateListener:)
- set(chatStateListener:) method
- set(currentOperatorChangeListener:) method
- set(departmentListChangeListener:)
- set(operatorTypingListener:) method
- set(locationSettingsChangeListener:) method
- set(onlineStatusChangeListener:) method
- set(unreadByOperatorTimestampChangeListener:) method
- set(unreadByVisitorMessageCountChangeListener:) method
- set(unreadByVisitorTimestampChangeListener:) method
- DataMessageCompletionHandler protocol
- SendFileCompletionHandler protocol
- RateOperatorCompletionHandler protocol
- VisitSessionStateListener protocol
- DepartmentListChangeListener protocol
- LocationSettings protocol
- ChatStateListener protocol
- CurrentOperatorChangeListener protocol
- OperatorTypingListener protocol
- LocationSettingsChangeListener protocol
- OnlineStatusChangeListener protocol
- UnreadByOperatorTimestampChangeListener protocol
- UnreadByVisitorMessageCountChangeListener protocol
- UnreadByVisitorTimestampChangeListener protocol
- ChatState enum
- OnlineStatus enum
- VisitSessionState enum
- DataMessageError enum
- SendFileError enum
- RateOperatorError enum
- MessageTracker protocol
- getLastMessages(byLimit:completion:) method
- getNextMessages(byLimit:completion:) method
- MessageListener protocol
- Message protocol
- MessageAttachment protocol
- ImageInfo protocol
- MessageType enum
- MessageSendStatus enum
- Department protocol
- DepartmentOnlineStatus enum
- Operator protocol
- WebimRemoteNotification protocol
- NotificationType enum
- NotificationEvent enum
- FatalErrorHandler protocol
- FatalErrorType enum
- WebimError protocol
- AccessError enum
- WebimLogger protocol
Set of static methods which are used for session object creating and working with remote notifications that are sent by Webim service.
Returns SessionBuilder class instance that is necessary to create WebimSession class instance.
Converts iOS remote notification object into WebimRemoteNotification object.
remoteNotification parameter takes [AnyHashable: Any] dictionary (which can be taken inside application(_ application:,didReceiveRemoteNotification userInfo:) AppDelegate class method from userInfo parameter).
Method can return nil if remoteNotification parameter value doesn't fit to Webim service remote notification format or if it doesn't contain any useful payload.
Preliminarily you can call method isWebim(remoteNotification:) on this value to know if this notification is send by Webim service.
Allows to know if particular remote notification object represents Webim service remote notification.
remoteNotification parameter takes [AnyHashable: Any] dictionary (which can be taken inside application(_ application:,didReceiveRemoteNotification userInfo:) AppDelegate class method from userInfo parameter).
Returns true or false.
Enumerates push notifications systems that can be used with WebimClientLibrary. Enum values are used to be passed to method set(remoteNotificationSystem:) SessionBuilder class instance method.
Apple Push Notification System.
App does not receive remote notification from Webim service.
Instance of this class is used to get WebimSession object. SessionBuilder class instance can be retreived with newSessionBuilder() Webim class method.
Sets Webim service account name.
accountName parameter – String-typed account name. Usually is represented by server URL (e.g. "https://demo.webim.ru"), but also can be just one word (e.g. "demo")
Returns self with account name set.
Method is mandatory to create WebimSession object.
Sets location name for the session.
location parameter – String-typed location name. Usually default available location names are "mobile" and "default". To create any other one you can contact service support.
Returns self with location name set.
Method is mandatory to create WebimSession object.
Sets app version number if it is necessary to differentiate its values inside Webim service.
appVersion parameter – optional String-typed app version.
Returns self with app version set. When passed nil it does nothing.
Method is not mandatory to create WebimSession object.
Sets visitor authorization data.
Without this method calling a visitor is anonymous, with randomly generated ID. This ID is saved inside app UserDefaults and can be lost (e.g. when app is uninstalled), thereby message history is lost too.
Authorized visitor data are saved by server and available with any device.
jsonString parameter – JSON-formatted String-typed visitor fields.
Returns self with visitor authorization data set.
Method is not mandatory to create WebimSession object.
Can't be used simultanously with set(providedAuthorizationTokenStateListener:,providedAuthorizationToken:) method.
Absolutely similar to method set(visitorFieldsJSONString jsonString:).
jsonData parameter – JSON-formatted Data-typed visitor fields.
When client provides custom visitor authorization mechanism, it can be realised by providing custom authorization token which is used instead of visitor fields.
Method sets ProvidedAuthorizationTokenStateListener object and provided authorization token. Setting custom token is optional, if is not set, library generates its own.
Returns self with visitor authorization data set.
Method is not mandatory to create WebimSession object.
Can't be used simultaneously with set(visitorFieldsJSONString:) or set(visitorFieldsJSONString:).
Sets chat title which is visible by an operator. Default value is "iOS Client"
pageTitle – String-typed chat title.
Returns self with chat title set.
Method is not mandatory to create WebimSession object.
Sets FatalErrorHandler object for session.
fatalErrorHandler parameter – any object of a class or struct that conforms to FatalErrorHandler protocol (or nil).
Returns self with FatalErrorHandler set. When nil passed it does nothing.
Method is not mandatory to create WebimSession object.
Sets remote notification system to use for receiving push notifications from Webim service.
remoteNotificationSystem parameter – RemoteNotificationSystem enum value. If parameter value is not NONE, set(deviceToken:) method is mandatory to be called too. With NONE value passed it does nothing.
Method is not mandatory to create WebimSession object.
Sets device token for push notification receiving.
deviceToken parameter – String-typed device token in hexadecimal format and without any spaces and service symbols.
Code example to convert device token to the right format:
let deviceToken = deviceToken.map { String(format: "%02.2hhx", $0) }.joined()
Returns self with device token set.
For the proper remote notifications configuration this method call is not sufficient. You have to call set(remoteNotificationSystem:) method too.
Method is not mandatory to create WebimSession object.
By default session saves message history inside SQLite DB file. To deactivate this functionality you can use this method with false parameter isLocalHistoryStoragingEnabled value (with true value passed it does nothing).
Returns self with the functionality activation setting.
Method is not mandatory to create WebimSession object.
Sets necesarity to clear all visitor data before session is created.
With false isVisitorDataClearingEnabled parameter value passed it does nothing.
Returns self with the functionality activation setting.
Method is not mandatory to create WebimSession object.
Method to pass WebimLogger object.
Parameter verbosityLevel – WebimLoggerVerbosityLevel case (can be skipped).
Returns self with the functionality activation setting.
Method is not mandatory to create WebimSession object.
Final method that returns WebimSession object. Can throw errors of SessionBuilderError type. The only two mandatory method to call preliminarily are set(accountName:) and set(location:).
Verbosity level of WebimLogger.
All available information will be delivered to WebimLogger instance with maximum verbosity level:
- session network setup parameters;
- network requests' URLs, HTTP method and parameters;
- network responses' HTTP codes, received data and errors;
- SQL queries and errors;
- full debug information and additional notes.
All information which is useful when debugging will be delivered to WebimLogger instance with necessary verbosity level:
- session network setup parameters;
- network requests' URLs, HTTP method and parameters;
- network responses' HTTP codes, received data and errors;
- SQL queries and errors;
- moderate debug information.
Reference information and all warnings and errors will be delivered to WebimLogger instance:
- network requests' URLS, HTTP method and parameters;
- HTTP codes and errors descriptions of failed requests.
- SQL errors.
Errors and warnings only will be delivered to WebimLogger instance:
- network requests' URLs, HTTP method, parameters, HTTP code and error description.
- SQL errors.
Only errors will be delivered to WebimLogger instance:
- network requests' URLs, HTTP method, parameters, HTTP code and error description.
Error types that can be throwed by SessionBuilder method build().
Error that is thrown when trying to create session object with nil account name.
Error that is thrown when trying to create session object with nil location name.
Error that is thrown when trying to use standard and custom visitor fields authentication simultaneously.
Error that is thrown when trying to create session object with invalid remote notifications configuration.
When client provides custom visitor authorization mechanism, it can be realised by providing custom authorization token which is used instead of visitor fields.
When provided authorization token is generated (or passed to session by client app), update(providedAuthorizationToken:) method is called. This method call indicates that client app must send provided authorisation token to its server which is responsible to send it to Webim service.
This mechanism can't be used as is. It requires that client server to support this mecahnism.
Method is called in two cases:
- Provided authorization token is genrated (or set by client app) and must be sent to client server which is responsible to send it to Webim service.
- Passed provided authorization token is not valid. Provided authorization token can be invalid if Webim service did not receive it from client server yet.
When this method is called, client server must send provided authorization token to Webim service.
providedAuthorizationTokenparameter contains provided authentication token which is set and which must be sent to Webim service by client server.
Provides methods to manipulate with WebimSession object.
Resumes session networking Session is created as paused. To start using it firstly you should call this method. Can throw errors of AccessError type.
Pauses session networking. If is already paused the method does nothing. Can throw errors of AccessError type.
Deactivates session. After that any session methods are not available. Can throw errors of AccessError type.
Returns MessageStream object attached to this session. Each invocation of this method returns the same object.
Changes location without creating a new session.
location parameter – new location name of String type.
Can throw errors of AccessError type.
Sets device token.
Provides methods to interact with Webim service.
Returns current session state (VisitSessionState type.
Returns current chat state of ChatState type.
Returns timestamp (of type Date) after which all chat messages are unread by operator (at the moment of last server update recieved).
Returns unread by visitor message count.
Returns timestamp (of type Date) after which all chat messages are unread by visitor (at the moment of last server update recieved) or nil if there's no unread by visitor messages.
Returns array of departments (Department) or nil if there're any or department list is not recieved yet.
Returns current LocationSettings object.
Returns Operator object of the current chat or nil if one does not exist.
Returns previous rating of the operator or 0 if it was not rated before.
id parameter – String-typed ID of operator.
Rates an operator.
To get an ID of the current operator call getCurrentOperator().
id parameter – String-typed ID of the operator to be rated. Optional: if nil is passed, current chat operator will be rated.
rating parameter – a number in range (1...5) that represents an operator rating. If the number is out of range, rating will not be sent to a server.
completionHandler parameter – RateOperatorCompletionHandler object.
Can throw errors of AccessError type.
Changes ChatState to QUEUE. Method call is not mandatory, send message or send file methods start chat automatically. If account settings provide automatic complimentary message it won't be sent before any "startChat" method or first sent message. Can throw errors of AccessError type.
Changes ChatState to QUEUE. Starts chat and sends first message simultaneously. Method call is not mandatory, send message or send file methods start chat automatically. If account settings provide automatic complimentary message it won't be sent before any "startChat" method or first sent message. Can throw errors of AccessError type.
Starts chat with particular department. Department is identified by departmentKey parameter (see getKey() of Department protocol)
Changes ChatState to QUEUE.
In most cases method call is not mandatory, send message or send file methods start chat automatically. But it is mandatory when VisitSessionState is in DEPARTMENT_SELECTION state.
If account settings provide automatic complimentary message it won't be sent before any "startChat" method or first sent message.
Can throw errors of AccessError type.
Starts chat with particular department and sends first message simultaneously. Department is identified by departmentKey parameter (see getKey() of Department protocol)
Changes ChatState to QUEUE.
In most cases method call is not mandatory, send message or send file methods start chat automatically. But it is mandatory when VisitSessionState is in DEPARTMENT_SELECTION state.
If account settings provide automatic complimentary message it won't be sent before any "startChat" method or first sent message.
Can throw errors of AccessError type.
Changes ChatState to CLOSED_BY_VISITOR. Can throw errors of AccessError type.
This method must be called whenever there is a change of the input field of a message transferring current content of a message as a parameter. When nil value passed it means that visitor stopped to type a message or deleted it.
When there's multiple calls of this method occured, draft message is sending to service one time per second.
Can throw errors of AccessError type.
Sends a text message.
When calling this method, if there is an active MessageTracker object. added(message newMessage:,after previousMessage:) method) with a message SENDING case in the status is also called.
message parameter – String-typed message text.
data parameter is optional, custom message parameters dictionary. Note that this functionality does not work as is – server version must support it.
completionHandler parameter – optional DataMessageCompletionHandler object.
Returns randomly generated String-typed ID of the message.
Can throw errors of AccessError type.
Sends a text message.
When calling this method, if there is an active MessageTracker object. added(message newMessage:,after previousMessage:) method) with a message SENDING case in the status is also called.
message parameter – String-typed message text.
isHintQuestion parameter shows to server if a visitor chose a hint (true value) or wrote his own text (false). Optional to use.
Returns randomly generated String-typed ID of the message.
Can throw errors of AccessError type.
Sends a file message.
When calling this method, if there is an active MessageTracker object. added(message newMessage:,after previousMessage:) method) with a message SENDING case in the status is also called.
file parameter – file represented in Data type.
filename parameter – file name of String type.
mimeType parameter – MIME type of the file to send of String type.
completionHandler parameter – optional SendFileCompletionHandler object.
Returns randomly generated String-typed ID of the message.
Can throw errors of AccessError type.
Returns MessageTracker object wich (via getNextMessages(byLimit limitOfMessages:,completion:)) allows to request the messages from above in the history. Each next call getNextMessages(byLimit limitOfMessages:,completion:) returns earlier messages in relation to the already requested ones. Changes of user-visible messages (e.g. ever requested from MessageTracker) are transmitted to MessageListener. That is why MessageListener object is needed when creating MessageTracker. For each MessageStream at every single moment can exist the only one active MessageTracker. When creating a new one at the previous there will be automatically called destroy(). Can throw errors of AccessError type.
Sets VisitSessionStateListener object to track changes of VisitSessionState.
Sets ChatStateListener object.
Sets CurrentOperatorChangeListener object.
Sets DepartmentListChangeListener object to track changes of department list.
Sets OperatorTypingListener object.
Sets LocationSettingsChangeListener object.
Sets OnlineStatusChangeListener object.
Sets UnreadByOperatorTimestampChangeListener object.
Sets UnreadByVisitorMessageCountChangeListener object.
Sets UnreadByVisitorTimestampChangeListener object.
Protocol which methods are called after send(message:data:completionHandler:) method is finished. Must be adopted.
Executed when operation is done successfully.
messageID parameter – ID of the appropriate message of String type.
Executed when operation is failed.
messageID parameter – ID of the appropriate message of String type.
error parameter – appropriate DataMessageError value.
Protocol which methods are called after send(file:filename:mimeType:completionHandler:) method is finished. Must be adopted.
Executed when operation is done successfully.
messageID parameter – ID of the appropriate message of String type.
Executed when operation is failed.
messageID parameter – ID of the appropriate message of String type.
error parameter – appropriate SendFileError value.
Protocol which methods are called after rateOperatorWith(id:byRating:completionHandler:) method is finished. Must be adopted.
Executed when operation is done successfully.
Executed when operation is failed.
error parameter – appropriate RateOperatorError value.
Provides methods to track changes of VisitSessionState status.
Called when VisitSessionState status is changed. Parameters contain its previous and new values.
Provides methods to track changes in departments list.
Called when department list is received. Current department list passed inside departmentList parameter and presents array of Department objects.
Interface that provides methods for handling LocationSettings which are received from server.
This method shows to an app if it should show hint questions to visitor. Returns true if an app should show hint questions to visitor, false otherwise.
Protocol that is to be adopted to track ChatState changes.
Called during ChatStatetransition. Parameters are of ChatState type.
Protocol that is to be adopted to track if current Operator object is changed.
Called when Operator object of the current chat changed. New one value can be nil (if an operator leaved the chat).
Protocol that is to be adopted to track if the operator started or ended to type a message.
Called when operator typing state changed.
Parameter isTyping is true if operator is typing, false otherwise.
Interface that provides methods for handling changes in LocationSettings.
Method called by an app when new LocationSettings object is received with parameters that represent previous and new LocationSettings objects.
Interface that provides methods for handling changes of session status.
Called when new session status is received with parameters that represent previous and new OnlineStatus values.
Interface that provides methods for handling changes of parameter that is to be returned by getUnreadByOperatorTimestamp() method. Can be set by set(unreadByOperatorTimestampChangeListener:) method.
Method to be called when parameter that is to be returned by getUnreadByOperatorTimestamp() method method is changed.
Interface that provides methods for handling changes of parameter that is to be returned by getUnreadByVisitorMessageCount() method. Can be set by set(unreadByVisitorMessageCountChangeListener:) method.
Method to be called when parameter that is to be returned by getUnreadByVisitorMessageCount() method method is changed.
Interface that provides methods for handling changes of parameter that is to be returned by getUnreadByVisitorTimestamp() method. Can be set by set(unreadByVisitorTimestampChangeListener:) method.
Method to be called when parameter that is to be returned by getUnreadByVisitorTimestamp() method method is changed.
A chat is seen in different ways by an operator depending on ChatState. The initial state is NONE. Then if a visitor sends a message (send(message:isHintQuestion:)), the chat changes it's state to QUEUE. The chat can be turned into this state by calling startChat() method. After that, if an operator takes the chat to process, the state changes to CHATTING. The chat is being in this state until the visitor or the operator closes it. When closing a chat by the visitor closeChat() method it turns into the state CLOSED_BY_VISITOR, by the operator - CLOSED_BY_OPERATOR. When both the visitor and the operator close the chat, it's state changes to the initial – NONE. A chat can also automatically turn into the initial state during long-term absence of activity in it. Furthermore, the first message can be sent not only by a visitor but also by an operator. In this case the state will change from the initial to INVITATION, and then, after the first message of the visitor, it changes to CHATTING.
Means that an operator has taken a chat for processing. From this state a chat can be turned into:
- CHATTING, if an operator intercepted the chat;
- CLOSED_BY_VISITOR, if a visitor closes the chat (closeChat() method);
- NONE, automatically during long-term absence of activity.
Means that chat is picked up by a bot. From this state a chat can be turned into:
- CLOSED_BY_OPERATOR, if an operator closes the chat;
- CLOSED_BY_VISITOR, if a visitor closes the chat (closeChat() method);
- NONE, automatically during long-term absence of activity.
Means that an operator has closed the chat. From this state a chat can be turned into:
- NONE, if the chat is also closed by a visitor (closeChat() method), or automatically during long-term absence of activity;
- QUEUE, if a visitor sends a new message (send(message:isHintQuestion:) method).
Means that a visitor has closed the chat. From this state a chat can be turned into:
- NONE, if the chat is also closed by an operator or automatically during long-term absence of activity;
- QUEUE, if a visitor sends a new message (send(message:isHintQuestion:) method).
Means that a chat has been started by an operator and at this moment is waiting for a visitor's response. From this state a chat can be turned into:
- CHATTING, if a visitor sends a message (send(message:isHintQuestion:) method);
- NONE, if an operator or a visitor closes the chat (closeChat() method).
Means the absence of a chat as such, e.g. a chat has not been started by a visitor nor by an operator. From this state a chat can be turned into:
- QUEUE, if the chat is started by a visitor (by the first message or by calling startChat() method);
- INVITATION, if the chat is started by an operator.
Means that a chat has been started by a visitor and at this moment is being in the queue for processing by an operator. From this state a chat can be turned into:
- CHATTING, if an operator takes the chat for processing;
- NONE, if a visitor closes the chat (by calling (closeChat() method) before it is taken for processing;
- CLOSED_BY_OPERATOR, if an operator closes the chat without taking it for processing.
The state is undefined. This state is set as the initial when creating a new session, until the first response of the server containing the actual state is got. This state is also used as a fallback if WebimClientLibrary can not identify the server state (e.g. if the server has been updated to a version that contains new states).
Online state possible cases.
Offline state with chats' count limit exceeded. Means that visitor is not able to send messages at all.
Online state with chats' count limit exceeded. Visitor is able send offline messages, but the server can reject it.
Visitor is able send offline messages.
Visitor is able to send both online and offline messages.
Session has not received first session status yet or session status is not supported by this version of the library.
Session possible states.
Chat in progress.
Chat must be started with department selected (there was a try to start chat without department selected).
Session is active but no chat is occuring (chat was not started yet).
Session is active but no chat is occuring (chat was closed recently).
Offline state.
First status is not recieved yet or status is not supported by this version of the library.
Error types that could be passed in onFailure(messageID:error:) method.
Received error is not supported by current WebimClientLibrary version.
To be raised when quoted message ID belongs to a message without canBeReplied flag set to true (this flag is to be set on the server-side).
To be raised when quoted message ID belongs to another visitor chat.
To be raised when quoted message ID belongs to multiple messages (server data base error).
To be raised when one or more required arguments of quoting mechanism are missing.
To be raised when wrong quoted message ID is sent.
Error types that could be passed in onFailure(messageID:error:) method.
The server may deny a request if the file size exceeds a limit. The maximum size of a file is configured on the server.
The server may deny a request if the file type is not allowed. The list of allowed file types is configured on the server.
Error types that could be passed in onFailure(error:) method.
Arised when trying to send operator rating request if no chat is exists.
Arised when trying to send operator rating request if passed operator ID doesn't belong to existing chat operator (or, in the same place, chat doesn't have an operator at all).
MessageTracker object has two purposes:
- it allows to request the messages which are above in the history;
- it defines an interval within which message changes are transmitted to the listener (see newMessageTracker(messageListener:) method).
Requests last messages from history. Returns not more than limitOfMessages of messages. If an empty list is passed inside completion, there no messages in history yet.
If there is any previous MessageTracker request that is not completed, or limit of messages is less than 1, or current MessageTracker has been destroyed, this method will do nothing.
Following history request can be fulfilled by getLastMessages(byLimit:completion:) method.
Completion is called with received array of Message objects as the parameter. It is guaranteed that completion will be called with empty or not result if call didn't throw an error. If current MessageTracker is destroyed completion will be called on empty result.
Can throw errors of AccessError type.
Requests the messages above in history. Returns not more than limitOfMessages of messages. If an empty list is passed inside completion, the end of the message history is reached.
If there is any previous MessageTracker request that is not completed, or limit of messages is less than 1, or current MessageTracker has been destroyed, this method will do nothing.
Notice that this method can not be called again until the callback for the previous call will be invoked.
Completion is called with received array of Message objects as the parameter. It is guaranteed that completion will be called with empty or not result if call didn't throw an error. If current MessageTracker is destroyed completion will be called on empty result.
Can throw errors of AccessError type.
Requests all messages from history. If an empty list is passed inside completion, there no messages in history yet.
If there is any previous MessageTracker request that is not completed, or current MessageTracker has been destroyed, this method will do nothing.
This method is totally independent on getLastMessages(byLimit:completion:) and getNextMessages(byLimit:completion:) methods calls.
Completion is called with received array of Message objects as the parameter. It is guaranteed that completion will be called with empty or not result if call didn't throw an error. If current MessageTracker is destroyed completion will be called on empty result.
Can throw errors of AccessError type.
MessageTracker retains some range of messages. By using this method one can move the upper limit of this range to another message.
If there is any previous MessageTracker request that is not completed, this method will do nothing.
Notice that this method can not be used unless the previous call getNextMessages(byLimit:completion:) was finished (completion handler was invoked).
Parameter message – Message object reset to.
Can throw errors of AccessError type.
Destroys the MessageTracker. It is impossible to use any MessageTracker methods after it was destroyed. Isn't mandatory to be called.
Should be adopted. Provides methods to track changes inside message stream.
Called when added a new message.
If previousMessage == nil then it should be added to the end of message history (the lowest message is added), in other cases the message should be inserted before the message (i.e. above in history) which was given as a parameter previousMessage.
Notice that this is a logical insertion of a message. I.e. calling this method does not necessarily mean receiving a new (unread) message. Moreover, at the first call getNextMessages(byLimit:completion:) most often the last messages of a local history (i.e. which is stored on a user's device) are returned, and this method will be called for each message received from a server after a successful connection.
Parameters are of type Message. previousMessage represents a message after which it is needed to make a message insert. If nil then an insert is performed at the end of the list.
Called when removing a message.
message parameter is of type Message.
Called when removed all the messages.
Called when changing a message. Message is an immutable type and field values can not be changed. That is why message changing occurs as replacing one object with another. Thereby you can find out, for example, which certain message fields have changed by comparing an old and a new object values. Parameters are of type Message.
Abstracts a single message in the message history.
A message is an immutable object. It means that changing some of the message fields creates a new object. Messages can be compared by using isEqual(to:) method for searching messages with the same set of fields or by ID (message1.getID() == message2.getID()) for searching logically identical messages. ID is formed on the client side when sending a message (send(message:isHintQuestion:) or send(file:filename:mimeType:completionHandler:)).
Messages of the types FILE_FROM_OPERATOR and FILE_FROM_VISITOR can contain attachments. Returns MessageAttachment object. Notice that this method may return nil even in the case of previously listed types of messages. E.g. if a file is being sent.
Messages of type ACTION_REQUEST contain custom dictionary.
Returns dictionary which contains custom fields or nil if there's no such custom fields.
Every message can be uniquefied by its ID. Messages also can be lined up by its IDs. ID doesn’t change while changing the content of a message.
Returns unique ID of the message of type String.
Returns ID of a message sender, if the sender is an operator, of type String.
Returns URL of a sender's avatar or nil if one does not exist.
Returns name of a message sender of type String.
Returns SENT if a message had been sent to the server, was received by the server and was delivered to all the clients; SENDING if not.
Returns text of the message of type String.
Returns Date the message was processed by the server.
Returns type of a message of MessageType type.
Method which can be used to compare if two Message objects have identical contents.
Returns true if two Message objects are identical and false otherwise.
Example code:
if messageOne.isEqual(to: messageTwo) { /* … */ }
Where messageOne and messageTwo are any Message objects.
Contains information about an attachment file.
Returns MIME-type of an attachment file of optional String type.
Returns name of an attachment file of optional String type.
If a file is an image, returns ImageInfo object; in other cases returns nil.
Returns attachment file size in bytes of Int64 type.
Returns URL of the file or nil.
Notice that this URL is short-living and is tied to a session.
Provides information about an image.
Returns a URL of an image thumbnail. The maximum width and height is usually 300 px but it can be adjusted at server settings. To get an actual preview size before file uploading is completed, 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
}
Notice that this URL is short-living and is tied to a session.
Returns height of an image in pixels of Int type or nil.
Returns width of an image in pixels of Int type or nil.
Message type representation.
A message from operator which requests some actions from a visitor. E.g. choose an operator group by clicking on a button in this message.
Message type that is received after operator clicked contacts request button. There's no this functionality automatic support yet. All payload is transfered inside standard text field.A message sent by an operator which contains an attachment.
A message sent by a visitor which contains an attachment.
A system information message. Messages of this type are automatically sent at specific events. E.g. when starting a chat, closing a chat or when an operator joins a chat.
A text message sent by an operator.
A system information message which indicates that an operator is busy and can't reply to a visitor at the moment.
A text message sent by a visitor.
Until a message is sent to the server, is received by the server and is spreaded among clients, message can be seen as "being send"; at the same time Message.getSendStatus() will return SENDING. In other cases - SENT.
A message is being sent.
A message had been sent to the server, received by the server and was spreaded among clients.
Single department entity. Provides methods to get department information. Department objects can be received through DepartmentListChangeListener protocol methods and getDepartmentList() method of MessageStream protocol.
Department key is used to start chat with some department. Presented by String object.
Used for startChat(departmentKey:) method of MessageStream protocol call.
Returns department public name. Presented by String object.
Returns department online status. Presented by DepartmentOnlineStatus object.
Returns order number.
Presented by Int value. Higher numbers match higher priority.
Returns dictionary of department localized names (if exists).
Presented by [String: String] dictonary. Key is custom locale descriptor, value is matching name.
Returns department logo URL (if exists).
Presented by URL object.
Possible department online statuses. Can be retreived by getDepartmentOnlineStatus() method of Department protocol.
Offline state with chats' count limit exceeded.
Online state with chats' count limit exceeded.
Visitor is able to send offline messages.
Visitor is able to send both online and offline messages.
Any status that is not supported by this version of the library.
Presents chat operator object.
Returns unique ID of the operator of String type.
Returns display name of the operator of String type.
Returns URL of the operator’s avatar or nil if does not exist.
Abstracts a remote notifications from Webim service.
Returns type of this remote notification of NotificationType type.
Returns event of this remote notification of NotificationEvent type or nil.
Returns parameters of this remote notification of array of type String type. Each NotificationType has specific list of parameters.
Represents payload type of remote notification.
This notification type indicated that contact information request is sent to a visitor.
Parameters: empty.
This notification type indicated that an operator has connected to a dialogue.
Parameters:
- Operator's name.
This notification type indicated that an operator has sent a file.
Parameters:
- Operator's name;
- File name.
This notification type indicated that an operator has sent a text message.
Parameters:
- Operator's name;
- Message text.
This notification type indicated that an operator has sent a widget message. This type can be received only if server supports this functionality.
Parameters: empty.
Represents meaned type of action when remote notification is received.
Means that a notification should be added by current remote notification.
Means that a notification should be deleted by current remote notification.
Must be adopted to handle service errors that can occur.
This method is to be called when Webim service error is received. Notice that method called NOT FROM THE MAIN THREAD!
error parameter is of WebimError type.
Webim service error types. Mind that most of this errors causes session to destroy.
Indicates that the account in Webim service has been disabled (e.g. for non-payment). The error is unrelated to the user’s actions. Recommended response is to show the user an error message with a recommendation to try using the chat later.
Notice that the session will be destroyed if this error occured.
Indicates that there was a try to perform action that requires existing chat, but there's no chat. E.g. see rateOperatorWith(id:,byRating rating:) method of MessageStream protocol.
Indicates an expired authorization of a visitor. The recommended response is to re-authorize it and to re-create session object.
Notice that the session will be destroyed if this error occured.
Indicates the occurrence of an unknown error. Recommended response is to send an automatic bug report and show to a user an error message with the recommendation to try using the chat later.
Notice that the session will be destroyed if this error occured.
Indicates that a visitor was banned by an operator and can't send messages to a chat anymore. Occurs when a user tries to open the chat or write a message after that. Recommended response is to show the user an error message with the recommendation to try using the chat later or explain to the user that it was blocked for some reason.
Notice that the session will be destroyed if this error occured.
Indicates a problem of your application authorization mechanism and is unrelated to the user’s actions. Occurs when trying to authorize a visitor with a non-valid signature. Recommended response is to send an automatic bug report and show the user an error message with the recommendation to try using the chat later.
Notice that the session will be destroyed if this error occured.
Abstracts Webim service possible fatal error.
Returns parsed type of the error of FatalErrorType type.
Returns String representation of an error. Mostly useful if the error type is unknown.
Error types that can be throwed by MessageStream methods.
Error that is thrown if the method was called not from the thread the WebimSession object was created in.
Error that is thrown if WebimSession object was destroyed.
Protocol that provides methods for implementing custom WebimClientLibrary network requests logging. It can be useful for debugging production releases if debug logs are not available.
Method which is called after new WebimClientLibrary network request log entry came out.
New log entry passed inside entry parameter.