tencent cloud

Chat

News and Announcements
Release Notes
Announcements
Product Introduction
Overview
Basic Concepts
Scenarios
Features
Account System
User Profile and Relationship Chain
Message Management
Group Related
Official Account
Audio/Video Call
Use Limits
Purchase Guide
Billing Overview
Pricing
Purchase Instructions
Renewal Guide
Service Suspension Explanation
Refund Policy
Development Guidelines
Demo Zone
Activate Service
Free Demos
Quick Run
Download
SDK and Demo Source Code
Update Log
Chat Interaction (UI Included)
TUIKit Introduction
Getting Started
Full-feature Integration
Single-function Integration
Build with AI
Build Basic Interfaces
More Features
Customizing Appearance
Internationalization
Push Service
Overview
Noun explanation
Activate the Service
Quick Start
Manufacturer Channel
Statistics
Troubleshooting Tool
Client APIs
REST API
Push Callback
Advanced Features
Release Notes
Error Codes
FAQS
Desk
Overview
Quick Start
Integration Guide
Admin Operation Manual
Agent Manual
More Practices
Live Streaming Setup Guide
AI Chatbot
Super Large Entertainment and Collaboration Community
Discord Implementation Guide
How to Integrate Chat into Games
WhatsApp Channel-style Official Account Integration Solution
Send Red Packet
Firewall Restrictions
No UI Integration
Quick Start
SDK Integration
Initialization
Login and Logout
Message
Conversation
Group
Community Topic
User Profile and Relationship Chain
Offline Push
Cloud Search
Local Search
Official Channel Management
Client APIs
JavaScript
Android
iOS & macOS
Swift
Flutter
Electron
Unity
React Native
C APIs
C++
Server APIs
Secure authentication with UserSig
RESTful APIs
Webhooks
Console Guide
New Console Introduction
Creating and Upgrading an Application
Basic Configuration
Feature Configuration
Account Management
Group Management
Official Channel Management
Webhook Configuration
Usage
Viewing Guide for Resource Packages
Real-Time Monitor
Auxiliary Development Tools
Access Management
Advanced Features
FAQs
uni-app FAQs
Purchase
SDK
Account Authentication
User Profile and Relationship Chain
Message
Group
Audio-Video Group
Nickname and Profile Photo
Security Compliance Certification
Service Level Agreement
Security Compliance Certification
Chat Policies
Privacy Policy
Data Privacy and Security Agreement
Migration
Migration Solutions
Migration Solutions Lite
Error Codes
Contact Us

iOS(SwiftUI)

PDF
Focus Mode
Font Size
Last updated: 2026-03-02 18:06:07

Component Overview

Search is a search component that provides users with a complete set of features, including a search box, search result display, and interface navigation. This component supports user search, group search, and message search, and offers a comprehensive set of interactive webhook interfaces.
Note:
Search function is available only in the Pro Edition or Enterprise Edition. You can use this feature after purchasing the Pro Edition or Enterprise Edition package. For details, see Pricing Information.
Search Entry
Search Results



Component Integration

The Search component is included in TUIKit SwiftUI. To use the Search component, integrate TUIKit SwiftUI into your project. For detailed integration steps, refer to the TUIKit SwiftUI documentation and complete the login process.

Component Structure

SearchBar serves as the entry point for search functionality. Only the initialization method of the search component is exposed externally; all other logic is encapsulated within SearchBar.
Method
Parameter
Description
init
onTapItem: @escaping (Any) -> Void
Webhook triggered when a search result is clicked, including friend, group, message, and conversation result items.

Basic Usage

The routing and navigation logic for SearchBar search results is as follows:
Automatic Routing: On the search results page, clicking the More button or the chat history list will automatically navigate to the corresponding page using the internal Navigator.
Custom Routing: When a user clicks a specific contact, group, conversation, or message, the component triggers the onTapItem: @escaping (Any) -> Void webhook. Implement your custom navigation logic in this webhook (for example, navigating to your custom chat interface).
Example code:
// Initialize SearchBar
SearchBar(onTapItem: { result in
handleSearchResult(result)
})

// Handle click events on search results
// The onConversationClick event is dispatched to a higher-level component. This is optional and can be adapted based on your project architecture.
private func handleSearchResult(_ result: Any) {
if let friendInfo = result as? FriendSearchInfo {
// Handle selection of a contact from search results
let conversationID = ChatUtil.getC2CConversationID(friendInfo.userID)
var conversation = ConversationInfo(conversationID: conversationID)
conversation.type = .c2c
conversation.title = friendInfo.friendRemark ?? friendInfo.userInfo.nickname
conversation.avatarURL = friendInfo.userInfo.avatarURL
// Dispatch event to the parent component to navigate to the C2C Chat list
onConversationClick?(NavigationInfo(conversation: conversation))
} else if let groupInfo = result as? GroupSearchInfo {
// Handle selection of a group from search results
let conversationID = ChatUtil.getGroupConversationID(groupInfo.groupID)
var conversation = ConversationInfo(conversationID: conversationID)
conversation.type = .group
conversation.title = groupInfo.groupName
conversation.avatarURL = groupInfo.groupAvatarURL
// Dispatch event to the parent component to navigate to the Group chat list
onConversationClick?(NavigationInfo(conversation: conversation))
} else if let messageDict = result as? [String: Any],
let messageInfo = messageDict["message"] as? MessageInfo,
let conversationID = messageDict["conversationID"] as? String
{
// Handle selection of a message result
var conversation = ConversationInfo(conversationID: conversationID)
if conversationID.hasPrefix("c2c_") {
conversation.type = .c2c
} else {
conversation.type = .group
}
conversation.title = messageDict["conversationName"] as? String
conversation.avatarURL = messageDict["conversationAvatar"] as? String
// Dispatch event to the parent component to navigate to the conversation and highlight the selected message
onConversationClick?(NavigationInfo(conversation: conversation, locateMessage: messageInfo))
} else if let conversationDict = result as? [String: Any],
let conversationID = conversationDict["conversationID"] as? String {
// Handle selection of a conversation result
var conversation = ConversationInfo(conversationID: conversationID)
if conversationID.hasPrefix("c2c_") {
conversation.type = .c2c
} else {
conversation.type = .group
}
conversation.title = conversationDict["conversationName"] as? String
conversation.avatarURL = conversationDict["conversationAvatar"] as? String
// Dispatch event to the parent component to navigate to the conversation
onConversationClick?(NavigationInfo(conversation: conversation))
}
}


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback