Link Search Menu Expand Document

Chat History

Table of contents

  1. Overview
    1. History management is out of the SDKs scope.
  2. How is it done
    1. ChatElementDelegate overview
  3. Basic Implementation
    1. Register To Delegate
    2. Implement ChatElementDelegate


History management is out of the SDKs scope.

The SDK enables the Host app to provide its own implementation, and maintain an updated chat history, by listening to triggered events whenever chat elements changes.

You can checkout an implementation example here.

How is it done

The hosting App provides a ChatElementDelegate implementation, on ChatController creation. This delegate should be fully implemented in order to be notified of all chat changes.
The SDK interacts with this delegate in order to fetch chat history on chat load, and to update history records, when chat elements were changed.

ChatElementDelegate overview

The ChatElementDelegate will be used for the following operations.

  • Fetch chat elements from stored history on chat load.
    Calling ChatElementDelegate.fetch

  • Notifies of an addition of chat element to the chat.
    Calling ChatEleChatElementDelegatementListener.didReceive

  • Notifies of removal of stored element from the chat.
    Calling ChatElementDelegate.didRemoveChatElement

  • Notifies of an update on chat element data.
    Calling ChatElementDelegate.didUpdateChatElement

  • Notifies of an update on chat element feedabck.
    Calling ChatElementDelegate.didUpdateFeedback

Basic Implementation

The following classes/interfaces are the public API for history managment:

  • ChatController - Use this class to set ChatElementDelegate.
  • Implement StorableChatElement to have your own storable chat element. (optional)

Register To Delegate

override func viewDidLoad() {
    controller.chatElementDelegate = self

Implement ChatElementDelegate

extension HistoryDemoViewController: ChatElementDelegate {
    func fetch(_ from: Int, handler: (([Any]?) -> Void)!) {

    func didReceive(_ item: StorableChatElement!) {

    func didRemoveChatElement(_ timestampId: TimeInterval) {

    func didUpdateChatElement(_ timestampId: TimeInterval, newTimestamp: TimeInterval, status: StatementStatus) {

    func didUpdateFeedback(_ articleId: String!, feedbackState: FeedbackStatus) {