TUIKit SwiftUI.login method of LoginStore to log in to the component.sdkAppID: The sdkAppID you obtained earlier.userID: The userID of the operator, which is user1 created in Quick Start.userSig: The userSig for the operator, which is the userSig for user1 created in Quick Start.// ContentView.swiftimport SwiftUIstruct ContentView: View {var body: some View {SearchPage()}}// SearchPage.swiftimport AtomicXimport AtomicXCoreimport SwiftUIpublic struct SearchPage: View {@StateObject private var themeState = ThemeState.shared@State private var isLoggedIn = false@State private var isLoggingIn = true@State private var loginError: String? = nilprivate let sdkAppID: Int32 = 1234567890 // TODO: Fill in the sdkAppID hereprivate let userID = "" // TODO: Fill in your userID hereprivate let userSig = "" // TODO: Fill in your generated userSig herepublic var body: some View {Group {if isLoggedIn {searchContentView} else if isLoggingIn {ProgressView("Logging in...")} else {VStack(spacing: 12) {Image(systemName: "exclamationmark.triangle").font(.system(size: 40)).foregroundColor(.orange)Text(loginError ?? "Login failed").foregroundColor(.secondary)}}}.environmentObject(themeState).onAppear {login()}}// MARK: - Search Contentprivate var searchContentView: some View {VStack(spacing: 0) {navigationBarViewDivider().background(.gray)// Add SearchBar to this page.SearchBar(onTapItem: { result inhandleSearchResult(result)}).padding(.vertical, 8)Spacer()}.background(themeState.colors.bgColorOperate.ignoresSafeArea(edges: .top))}// MARK: - Navigation Barprivate var navigationBarView: some View {HStack {Image(systemName: "magnifyingglass").font(.system(size: 24)).foregroundColor(.gray)Text("Search").font(.system(size: 17, weight: .semibold)).foregroundColor(themeState.colors.textColorPrimary)Spacer()}.padding(.horizontal, 16).frame(height: 44)}// MARK: - Handle Search Resultprivate func handleSearchResult(_ result: Any) {if let friendInfo = result as? FriendSearchInfo {// Handle friend search resultlet conversationID = ChatUtil.getC2CConversationID(friendInfo.userID)print(">>>>> Search result - Friend: \\(friendInfo.userID), conversationID: \\(conversationID)")} else if let groupInfo = result as? GroupSearchInfo {// Handle group search resultlet conversationID = ChatUtil.getGroupConversationID(groupInfo.groupID)print(">>>>> Search result - Group: \\(groupInfo.groupID), conversationID: \\(conversationID)")} else if let messageDict = result as? [String: Any],let messageInfo = messageDict["message"] as? MessageInfo,let conversationID = messageDict["conversationID"] as? String{// Handle message search result (from search detail view)let conversationName = messageDict["conversationName"] as? String ?? "Unknown"print(">>>>> Search result - Message in \\(conversationName), conversationID: \\(conversationID), messageID: \\(messageInfo.id)")} else if let conversationDict = result as? [String: Any],let conversationID = conversationDict["conversationID"] as? String{// Handle conversation search result (from detail view)let conversationName = conversationDict["conversationName"] as? String ?? "Unknown"print(">>>>> Search result - Conversation: \\(conversationName), conversationID: \\(conversationID)")} else {print(">>>>> Search result - Unknown type: \\(result)")}}// MARK: - Loginprivate func login() {guard !userSig.isEmpty else {isLoggingIn = falseloginError = "userSig is empty. Please fill in a valid userSig."return}// Login is required when page appears.LoginStore.shared.login(sdkAppID: sdkAppID, userID: userID, userSig: userSig) { result inswitch result {case .success:print(">>>>> SearchPage login success, userID: \\(userID)")isLoggedIn = trueisLoggingIn = falsecase .failure(let error):print(">>>>> SearchPage login failed: \\(error.code), \\(error.message)")loginError = "Login failed: \\(error.code), \\(error.message)"isLoggingIn = false}}}}

fileName parameter when creating the message, which will be indexed for search. If fileName is not set, the file name is extracted from filePath and stored locally and on the server.Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan