ZohoSalesIQChatDelegate
The Mobilisten iOS SDK provides a delegate for various chat event callbacks to help developers track different actions performed by the app user.
ZohoSalesIQChatDelegate Implementation
To start receiving various events within the Mobilisten, your class must conform to the ZohoSalesIQChatDelegate protocol. Then, set an instance of your class to the ZohoSalesIQ.Chat.delegate property to set your class as the delegate. The delegate methods give an instance of the SIQVisitorChat class, which contains information related to the chat.
SIQVisitorChat class contains the following properties:
Property | Description |
referenceID | ID of the chat |
question | The question with which the chat was started |
unreadCount | Unread message count of the chat |
feedback | Feedback provided for the chat |
rating | The rating given for the chat |
status | Status of the chat |
queuePosition | Position in the queue for a queued chat. Note: The queue position is -1 if the chat is not queued. |
attenderID | Unique ID of the chat attender |
isBotAttender | Flag to check if the chat is last attended by a bot |
departmentName | Department to which the chat is connected to |
attenderName | Name of the chat attender |
attenderEmail | Email ID of the chat attender |
Last Message:
LastMessage shows the properties of the chat. A chat can have the following properties:
Last Message | Description |
.lastMessage.time | Time of the last message sent in chat |
.lastMessage.sender | Name of the sender of the last message |
.lastMessage.isRead | To check if the last message was read |
.lastMessage.isEdited | To check if the last message was edited |
.lastMessage.isDeleted | To check if the last message was deleted |
.lastMessage.file | If the last message is a file, this property will return the details of the file |
.lastMessage.file.name | File name of the last message |
.lastMessage.file.size | File size of the last message |
.lastMessage.file.contentType | File type of the last message (Ex: Image, gif, video,etc) |
.lastMessage.file.comment | File comment of the last message |
Supported chat event callbacks
Method | Invoked when |
chatOpened | a new chat is initiated by the user |
chatAttended | a chat is picked up by an operator or bot |
chatMissed | a chat goes missed |
chatClosed | a chat is closed |
chatReopened | a chat is reopened |
chatRatingRecieved | a user rate the chat session |
chatFeedbackRecieved | a user provides feedback about the chat session |
unreadCountChanged | a unread chat count changes |
chatQueuePositionChanged | the queue position of a chat is updated |
shouldOpenURL | a URL is tapped/clicked in the chat |
handleNotificationAction | a notification is tapped (when using Notification.setAction()) |
Setting the delegate
Copiedlet myChatEventHandler = MyChatEventHandler()
ZohoSalesIQ.Chat.delegate = myChatEventHandler
Implementation:
Copiedclass MyChatEventHandler: ZohoSalesIQChatDelegate{
func chatOpened(chat: SIQVisitorChat?) {
// your code goes here
}
func chatQueuePositionChanged(chat: SIQVisitorChat?) {
// your code goes here
}
func chatAttended(chat: SIQVisitorChat?) {
// your code goes here
}
func chatMissed(chat: SIQVisitorChat?) {
// your code goes here
}
func chatClosed(chat: SIQVisitorChat?) {
// your code goes here
}
func chatReopened(chat: SIQVisitorChat?) {
// your code goes here
}
func chatRatingRecieved(chat: SIQVisitorChat?) {
// your code goes here
}
func chatFeedbackRecieved(chat: SIQVisitorChat?) {
// your code goes here
}
func unreadCountChanged(_ count: Int) {
// your code goes here
}
func shouldOpenURL(_ url: URL, in chat: SIQVisitorChat?) -> Bool {
// your code to handle URL goes here
return true // return false to disable default behavior
}
func handleNotificationAction(payload: [String : Any]) {
// use the Notification.getPayload() API
}
}