In-app Chat Kit
  • iOS : Swift
  • Android
  • Flutter
  • React Native
  • Overview
  • Quick start
  • UI components
    • Overview
    • Conversation component
    • Message component
  • Advanced features
  • Documentation
  • In-app Chat UIKit
  • UI components
  • Session component

Conversation component

Last updated:2023-03-30 14:41

The conversation component of the In-app Chat Kit provides the chat list and chat features.

  • Chat list: Allow you to view the data of your chat list and support automatic update of the chat list based on chat messages.
  • Chat: Create one-on-one chats and group chats.

Integrate the conversation component into your project

Prerequisites

Integrate the In-app Chat Kit SDK into your project (finished the initialization and login are required). For more information, see Quick start.

Add the conversation component

  1. Import the In-app Chat Kit module.
import UIKit
import ZIMKit

/// your ViewController.swift
class ViewController: UIViewController {

}
  1. Display the chat list component.
import UIKit
import ZIMKit

/// your ViewController.swift
class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

    }

    /// Call the following method to display the chat list after login succeeded.
    func showConversationListVC(_ sender: Any) {
        let conversationVC = ZIMKitConversationListVC()
        let nav = UINavigationController(rootViewController: conversationVC)
        nav.modalPresentationStyle = .fullScreen
        self.present(nav, animated: true)
    }
}

Customize features

If the default conversation-relevant features and behaviors don't fully meet your needs, we allow you to flexibly customize those through the config we mentioned in this section.

1. Custom click event

To customize click event logic, you can listen to the callback on a Conversation clicked by implementing the delegate ZIMKitConversationListVCDelegate.

import UIKit
import ZIMKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.

        let conversationVC = ZIMKitConversationListVC()
        conversationVC.delegate = self
    }
}

extension ViewController: ZIMKitConversationListVCDelegate {

    /// Callback on a conversation clicked.
    /// - Parameters:
    ///   - conversationListVC: ZIMKitConversationListVC
    ///   - conversation: conversation model
    ///   - defaultAction: Clicking will jump to the message page by default.
    func conversationList(_ conversationListVC: ZIMKitConversationListVC, didSelectWith conversation: ZIMKitConversation, defaultAction: () -> ()) {
        // You can add your event handling logic here.
    }
}
Page Directory