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:

PropertyDescription
referenceIDID of the chat
questionThe question with which the chat was started
unreadCountUnread message count of the chat
feedbackFeedback provided for the chat
ratingThe rating given for the chat
statusStatus of the chat
queuePosition

Position in the queue for a queued chat.

Note: The queue position is -1 if the chat is not queued.

attenderIDUnique ID of the chat attender
isBotAttenderFlag to check if the chat is last attended by a bot
departmentNameDepartment to which the chat is connected to
attenderNameName of the chat attender
attenderEmailEmail ID of the chat attender

Last Message:

 LastMessage shows the properties of the chat. A chat can have the following properties:

Last MessageDescription
.lastMessage.timeTime of the last message sent in chat
.lastMessage.senderName of the sender of the last message
.lastMessage.isReadTo check if the last message was read
.lastMessage.isEditedTo check if the last message was edited
.lastMessage.isDeletedTo check if the last message was deleted
.lastMessage.fileIf the last message is a file, this property will return the details of the file
.lastMessage.file.nameFile name of the last message
.lastMessage.file.sizeFile size of the last message
.lastMessage.file.contentTypeFile type of the last message (Ex: Image, gif, video,etc)
.lastMessage.file.commentFile comment of the last message

Supported chat event callbacks

MethodInvoked when
chatOpeneda new chat is initiated by the user
chatAttendeda chat is picked up by an operator or bot
chatMisseda chat goes missed
chatCloseda chat is closed
chatReopeneda chat is reopened
chatRatingRecieveda user rate the chat session
chatFeedbackRecieveda user provides feedback about the chat session
unreadCountChangeda unread chat count changes
chatQueuePositionChangedthe queue position of a chat is updated
shouldOpenURLa URL is tapped/clicked in the chat
handleNotificationActiona 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
    }
}