Commit fe3bceeb authored by Alex朱枝文's avatar Alex朱枝文

添加银河账号登录腾讯IM

parent 9134dc59
......@@ -30,9 +30,9 @@ def tencentIM_pods
pod 'TUISearch', :path => "../TUIKit/TUISearch"
# 集成音视频通话功能
# pod 'TUICallKit_Swift/Professional', '2.7.0.1145'
pod 'TUICallKit_Swift/Professional', '3.0.0.685'
# 集成快速会议
# pod 'TUIRoomKit/Professional', '3.0.1'
pod 'TUIRoomKit/Professional', '3.0.1'
# 集成TUIKitPlugin插件 (可选)
# 注意: TUIKitPlugin插件需要跟随TUICore的版本
......@@ -128,7 +128,7 @@ target 'galaxy' do
# #骨架图
# pod 'SkeletonView','1.30.4'
#导航栏、手势
pod 'GKNavigationBarSwift','1.6.5'
pod 'GKNavigationBarSwift','1.6.8'
#crash统计
pod 'Bugly','2.6.1'
#神策数据分析
......
......@@ -1277,6 +1277,7 @@
04EA376D2BEA06EF00DBAF64 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 04EA376C2BEA06EF00DBAF64 /* WebKit.framework */; };
04EA376F2BEA071600DBAF64 /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 04EA376E2BEA070500DBAF64 /* libc++.tbd */; };
04FE44D42DDC766E009BB247 /* TUIChatCustomTheme.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 04FE44D32DDC766D009BB247 /* TUIChatCustomTheme.bundle */; };
04FE44DA2DDEF0D1009BB247 /* YHTUIMessageListManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04FE44D92DDEF0D1009BB247 /* YHTUIMessageListManager.swift */; };
6203A87EDC96313BBE789D9C /* Pods_galaxy.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 987C69D43AE8D85DC1930DCF /* Pods_galaxy.framework */; };
A5573EE92B317C0100D98EC0 /* galaxyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5573EE82B317C0100D98EC0 /* galaxyTests.swift */; };
A5573EF32B317C0100D98EC0 /* galaxyUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5573EF22B317C0100D98EC0 /* galaxyUITests.swift */; };
......@@ -2592,6 +2593,7 @@
04EA376E2BEA070500DBAF64 /* libc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; };
04FA8B2D2C084C7E00ABE43F /* ATAuthSDK.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = ATAuthSDK.bundle; path = "galaxy/Classes/Modules/AutoLogin(一键登录)/framework/ATAuthSDK_D.framework/ATAuthSDK.bundle"; sourceTree = "<group>"; };
04FE44D32DDC766D009BB247 /* TUIChatCustomTheme.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = TUIChatCustomTheme.bundle; sourceTree = "<group>"; };
04FE44D92DDEF0D1009BB247 /* YHTUIMessageListManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHTUIMessageListManager.swift; sourceTree = "<group>"; };
19B28612265782F9DC1BE0B0 /* Pods-galaxy.testenv.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-galaxy.testenv.xcconfig"; path = "Target Support Files/Pods-galaxy/Pods-galaxy.testenv.xcconfig"; sourceTree = "<group>"; };
58C2405158A4A6632D0E7460 /* Pods-galaxy.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-galaxy.debug.xcconfig"; path = "Target Support Files/Pods-galaxy/Pods-galaxy.debug.xcconfig"; sourceTree = "<group>"; };
987C69D43AE8D85DC1930DCF /* Pods_galaxy.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_galaxy.framework; sourceTree = BUILT_PRODUCTS_DIR; };
......@@ -3052,6 +3054,7 @@
045C0A632D12CA5E00BD2DC0 /* YHButlerServiceManager.swift */,
0465A3E52DC1B9D500CBCEE9 /* YHTencentDeskManager.swift */,
045C0A642D12CA5E00BD2DC0 /* YHButlerServiceMessageHandler.swift */,
04FE44D92DDEF0D1009BB247 /* YHTUIMessageListManager.swift */,
);
path = "ButlerServiceManager(银河管家)";
sourceTree = "<group>";
......@@ -7617,6 +7620,7 @@
045C111E2D12CA5F00BD2DC0 /* YHPreviewAcademicAndProfessionalQualificationViewController.swift in Sources */,
045C111F2D12CA5F00BD2DC0 /* YHWorkExperienceTableViewCell.swift in Sources */,
04307BAA2D1FF74500ED8E8D /* YHRecommendLiveListModel.swift in Sources */,
04FE44DA2DDEF0D1009BB247 /* YHTUIMessageListManager.swift in Sources */,
0411CF182D1D502D00644D35 /* YHlifeCollectionReusableView.swift in Sources */,
045C11202D12CA5F00BD2DC0 /* UITextField+Extension.swift in Sources */,
045C11212D12CA5F00BD2DC0 /* YHPlayer.swift in Sources */,
......
......@@ -211,7 +211,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate {
// QiYu SDK初始化
YHButlerServiceManager.shared.setupSDK()
setupTUITheme()
YHTencentDeskManager.shared.loginIM()
// YHTencentDeskManager.shared.loginIM()
_ = YHTencentDeskManager.shared
// 初始化 环信IM SDK
DispatchQueue.main.async {
......
......@@ -91,6 +91,8 @@ class YHTabBarViewController: ESTabBarController {
NotificationCenter.default.addObserver(self, selector: #selector(clearFriendTabBadge), name: YhConstant.YhNotification.didMarkAllMessagesReadedNotifiction, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(getTotalUnreadMsgCount), name: YhConstant.YhNotification.didTxIMUnReadMsgCountChangeNotification, object: nil)
}
@objc func getTotalUnreadMsgCount() {
......@@ -106,6 +108,7 @@ class YHTabBarViewController: ESTabBarController {
if YHButlerServiceManager.shared.isUatAllowed() {
unreadCount = self.msgViewModel.unreadTotalCount + YHButlerServiceManager.shared.unreadCount
}
unreadCount += Int(YHTUIMessageListManager.shared.getTotalUnreadCount())
// 朋友tab小红点显示逻辑
self.showFriendTabRedBadgeNumber(unreadCount)
}
......
......@@ -10,6 +10,8 @@ import Foundation
class YHButlerServiceViewModel {
var userSig: String?
/// 获取透传个人信息
func getUserInfomation(_ id: String, callBackBlock: @escaping (_ dataString: String?, _ avatar: String?, _ groupTmpId: Int64?, _ error: YHErrorModel?) -> Void) {
let params: [String: Any] = ["yh_id": id]
......@@ -61,4 +63,25 @@ class YHButlerServiceViewModel {
callBackBlock(false, err)
}
}
/*
userSig
*/
func getUsersig(callBackBlock: @escaping (_ success: Bool?, _ error: YHErrorModel?) -> Void) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.TencentIM.getUsersig
_ = YHNetRequest.postRequest(url: strUrl, params: [:]) {
json, _ in
printLog("model 是 ==> \(json)")
if json.code == 200 {
self.userSig = json.data?.peel as? String
callBackBlock(true, nil)
} else {
let error: YHErrorModel = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { error in
callBackBlock(false, error)
}
}
}
//
// YHTUIMessageListManager.swift
// galaxy
//
// Created by alexzzw on 2025/5/22.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import Foundation
import ImSDK_Plus
import TUIConversation
// 消息列表代理
public protocol YHMessageListDelegate: AnyObject {
func onMessageListDataSourceChanged()
func onMessageSelected(message: TUIConversationCellData)
func onUnreadCountChanged(unreadCount: Int, hideUnreadCount: Int)
// 可选实现的自定义消息显示
func getCustomMessageDisplay(conversation: V2TIMConversation) -> String?
}
// 扩展协议默认实现
public extension YHMessageListDelegate {
func getCustomMessageDisplay(conversation: V2TIMConversation) -> String? {
return nil
}
}
public class YHTUIMessageListManager: NSObject {
public static let shared = YHTUIMessageListManager()
private let dataProvider: TUIConversationListDataProvider = TUIConversationListDataProvider()
private var messageList: [TUIConversationCellData] = []
public weak var delegate: YHMessageListDelegate?
private var unreadCount: UInt64 = 0
override private init() {
super.init()
setupDataProvider()
}
private func setupDataProvider() {
dataProvider.delegate = self
V2TIMManager.sharedInstance().addConversationListener(listener: self)
getTotalUnreadCount(unreadMessageCountEvent: { [weak self] count, msg in
if msg != nil {
self?.unreadCount = count
}
})
}
func getTotalUnreadCount(unreadMessageCountEvent: @escaping (UInt64, String?) -> Void) {
V2TIMManager.sharedInstance().getTotalUnreadMessageCount { count in
unreadMessageCountEvent(count, nil)
} fail: { _, msg in
unreadMessageCountEvent(0, msg)
}
}
func getTotalUnreadCount() -> UInt64 {
return unreadCount
}
// MARK: - Public Methods
/// 获取消息列表
public func getMessageList() -> [TUIConversationCellData] {
return messageList
}
/// 刷新消息列表
public func refreshMessageList() {
dataProvider.loadNexPageConversations()
}
/// 删除会话
public func deleteConversation(_ item: TUIConversationCellData) {
guard let conversation = findConversationData(for: item.conversationID) else {
return
}
dataProvider.removeConversation(conversation)
}
/// 标记会话已读
public func markAsRead(_ item: TUIConversationCellData) {
guard let conversation = findConversationData(for: item.conversationID) else {
return
}
dataProvider.markConversation(asRead: conversation)
}
/// 标记会话未读
public func markAsUnread(_ item: TUIConversationCellData) {
guard let conversation = findConversationData(for: item.conversationID) else {
return
}
dataProvider.markConversation(asUnRead: conversation)
}
/// 置顶会话
public func pinConversation(_ item: TUIConversationCellData, isPinned: Bool) {
guard let conversation = findConversationData(for: item.conversationID) else {
return
}
dataProvider.pinConversation(conversation, pin: isPinned)
}
/// 清空会话历史消息
public func clearHistoryMessage(_ item: TUIConversationCellData) {
guard let conversation = findConversationData(for: item.conversationID) else {
return
}
dataProvider.clearHistoryMessage(conversation)
}
// MARK: - Private Methods
private func findConversationData(for conversationID: String) -> TUIConversationCellData? {
let conversationList = dataProvider.conversationList as? [TUIConversationCellData] ?? []
return conversationList.first { $0.conversationID == conversationID }
}
private func updateMessageList() {
let conversationList = dataProvider.conversationList as? [TUIConversationCellData] ?? []
messageList = conversationList
// 通知UI更新
DispatchQueue.main.async { [weak self] in
self?.delegate?.onMessageListDataSourceChanged()
}
}
}
// MARK: - TUIConversationListDataProviderDelegate
extension YHTUIMessageListManager: TUIConversationListDataProviderDelegate {
public func getConversationDisplayString(_ conversation: V2TIMConversation) -> String {
return delegate?.getCustomMessageDisplay(conversation: conversation) ?? ""
}
public func insertConversations(atIndexPaths indexPaths: [Any]) { // IndexPath
updateMessageList()
}
public func deleteConversation(atIndexPaths indexPaths: [Any]) {
updateMessageList()
}
public func reloadConversations(atIndexPaths indexPaths: [Any]) {
updateMessageList()
}
public func reloadAllConversations() {
updateMessageList()
}
public func updateMarkUnreadCount(_ markUnreadCount: Int, markHideUnreadCount: Int) {
DispatchQueue.main.async { [weak self] in
self?.delegate?.onUnreadCountChanged(unreadCount: markUnreadCount,
hideUnreadCount: markHideUnreadCount)
}
}
}
extension YHTUIMessageListManager: V2TIMConversationListener {
public func onTotalUnreadMessageCountChanged(totalUnreadCount: UInt64) {
printLog("totalUnreadCount: \(totalUnreadCount)")
unreadCount = totalUnreadCount
NotificationCenter.default.post(name: YhConstant.YhNotification.didTxIMUnReadMsgCountChangeNotification, object: nil)
}
}
......@@ -7,7 +7,6 @@
//
import IQKeyboardManagerSwift
// import TencentCloudAIDeskCustomer
import UIKit
import TUICore
......@@ -15,33 +14,91 @@ class YHTencentDeskManager: NSObject {
static let shared = YHTencentDeskManager()
private lazy var viewModel: YHButlerServiceViewModel = YHButlerServiceViewModel()
private override init() {
super.init()
NotificationCenter.default.addObserver(self, selector: #selector(loginSuccess), name: YhConstant.YhNotification.didLoginSuccessNotifiction, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(logoutSuccess), name: YhConstant.YhNotification.didLogoutSuccessNotifiction, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(didRevUatParam), name: YhConstant.YhNotification.didRevUatParam, object: nil)
if isUatAllowed() {
loginSDK()
}
}
@MainActor func login() {
// guard let userId = YHLoginManager.shared.userModel?.id, userId.count > 0 else {
// return
// }
let users: [String: String] = ["1": "eJyrVgrxCdYrSy1SslIy0jNQ0gHzM1NS80oy0zLBwoZQweKU7MSCgswUJStDMwMDAwtTY0MTiExqRUFmUSpQ3NTU1AgoBREtycwFiZmbmBtZmhsZmEJNyUwHmhnoU*6YmBJZEaMfWmyWbeDuYhRu6RaSkuQco58fllQQ7J9jYFmcFejnW6GdZ2GrVAsAYeYv3A__", "3": "eJyrVgrxCdYrSy1SslIy0jNQ0gHzM1NS80oy0zLBwsZQweKU7MSCgswUJStDMwMDAwtTY0MTiExqRUFmUSpQ3NTU1AgoBREtycwFiZmbmJkZAkVNoaZkpgPNDIoyTCw2DHIPCfQySDbPMCnOTQsszyoNjNGvCgj1N8nwDfFNy-QMTQnL9i62VaoFADNSMAk_", "5": "eJwtzE8LgjAcxvH3snPY-rYpdIsdskuYUNBF2JTfzFw2Koree0s9Pp8Hvh902BXJww4oQzTBaDFuMPYaoIaRxYx301beg0EZWWGMlWCET499eRhsdCEEjdekAbq-SS5pmnIl5wo0sXl0pa6fYXM7L8vCbSXRJvTkDTxvzd5qzNSpyi*1dx3r1*j7A0a1MDw_"]
let key = "1"
// TencentCloudCustomerManager.shared().login(withSdkAppID: YhConstant.TencentIMSDKInfo.sdkAppID, userID: key, userSig: users[key]) { _ in
// //
// }
// IQKeyboardManager.shared.disabledDistanceHandlingClasses.append(TDeskC2CChatViewController.self)
// IQKeyboardManager.shared.disabledDistanceHandlingClasses.append(TDeskBaseChatViewController.self)
deinit {
NotificationCenter.default.removeObserver(self)
}
func loginIM() {
let users: [String: String] = ["1": "eJyrVgrxCdYrSy1SslIy0jNQ0gHzM1NS80oy0zLBwoZQweKU7MSCgswUJStDMwMDAwtTY0MTiExqRUFmUSpQ3NTU1AgoBREtycwFiZmbmBtZmhsZmEJNyUwHmhnoU*6YmBJZEaMfWmyWbeDuYhRu6RaSkuQco58fllQQ7J9jYFmcFejnW6GdZ2GrVAsAYeYv3A__", "3": "eJyrVgrxCdYrSy1SslIy0jNQ0gHzM1NS80oy0zLBwsZQweKU7MSCgswUJStDMwMDAwtTY0MTiExqRUFmUSpQ3NTU1AgoBREtycwFiZmbmJlZmJoZGENNyUwHmlnoHObvGx4cmZjvnF5VVhmU4ZvtX2QZZOpZ4Ztv7OJmamSZ5B4So19ualyZbKtUCwBFAi-S", "15272": "eJyrVgrxCdYrSy1SslIy0jNQ0gHzM1NS80oy0zLBwoamRuZGUInilOzEgoLMFCUrQzMDAwMLU2NDE4hMakVBZlEqUNzU1NQIKAURLcnMBYmZm5gbm1uYWhpCTclMB5pbVR6Z6KXtZxlsnJvt5Btaqm0YaRmUH1Qclh1u6OOaahienFdaku7jZljsaKtUCwCa0DA7", "2": "eJyrVgrxCdYrSy1SslIy0jNQ0gHzM1NS80oy0zIhwlDB4pTsxIKCzBQlK0MzAwMDC1NjQxOITGpFQWZRKlDc1NTUCCgFES3JzAWJmZuYmxsbGVsaQU3JTAeaaVie7WMQ5GnkVZllkeVVVeXnVOBXGVxg5GThYlRkahheZBae6BgYXurp52urVAsAAVUvGg__"]
let key = "3"
let key = "2"
let success: TSucc? = {
print("loginIM success")
printLog("loginIM success")
_ = YHTUIMessageListManager.shared
}
let failure: TFail? = { code, msg in
print("loginIM failure: code: \(code) msg: \(msg ?? "")")
printLog("loginIM failure: code: \(code) msg: \(msg ?? "")")
}
TUILogin.login(YhConstant.TencentIMSDKInfo.sdkAppID, userID: key, userSig: users[key] ?? "", succ: success, fail: failure)
}
func loginSDK() {
guard let userId = YHLoginManager.shared.userModel?.id, userId.count > 0 else {
return
}
viewModel.getUsersig { [weak self] success, _ in
guard let self = self else {
return
}
if success == true {
let userSig = self.viewModel.userSig ?? ""
let success: TSucc? = {
printLog("loginIM success")
_ = YHTUIMessageListManager.shared
}
let failure: TFail? = { code, msg in
printLog("loginIM failure: code: \(code) msg: \(msg ?? "")")
}
TUILogin.login(YhConstant.TencentIMSDKInfo.sdkAppID, userID: userId, userSig: userSig, succ: success, fail: failure)
}
}
}
}
extension YHTencentDeskManager {
// MARK: - 常用公开方法
/// 灰度打开
func isUatAllowed() -> Bool {
let allowed = YHUatHelper.shared.getUatModuleStatusBy(module: .QiYu_Service) == 1
return allowed
}
@objc private func didRevUatParam() {
guard isUatAllowed() else {
return
}
loginSDK()
}
@objc private func loginSuccess() {
guard isUatAllowed() else {
return
}
loginSDK()
}
@objc private func logoutSuccess() {
let success: TSucc? = {
printLog("logout success")
_ = YHTUIMessageListManager.shared
}
let failure: TFail? = { code, msg in
printLog("logout failure: code: \(code) msg: \(msg ?? "")")
}
TUILogin.logout(success, fail: failure)
}
}
......@@ -90,8 +90,6 @@ class YHMyFileListViewController: YHBaseViewController {
lazy var headerView: UIView = {
// 是否为刘海屏
let isNotchScreen = GKDevice.isNotchedScreen
let top = 88-k_Height_NavigationtBarAndStatuBar
let myView = UIView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: originHeaderHeight))
myView.clipsToBounds = true
......
......@@ -90,8 +90,6 @@ class YHGCMyFileListViewController: YHBaseViewController {
lazy var headerView: UIView = {
// 是否为刘海屏
let isNotchScreen = GKDevice.isNotchedScreen
let top = 88-k_Height_NavigationtBarAndStatuBar
let myView = UIView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: originHeaderHeight))
myView.clipsToBounds = true
......
......@@ -163,10 +163,10 @@ func goTabBarBy(tabType: TabBarPageType) {
}
}
func goToMessagePage() {
func goToMessagePage(_ userInfo: [AnyHashable: Any]? = nil) {
goTabBarBy(tabType: .community)
UIViewController.current?.navigationController?.popToRootViewController(animated: true)
NotificationCenter.default.post(name: YhConstant.YhNotification.goMessageVCNotifiction, object: nil)
NotificationCenter.default.post(name: YhConstant.YhNotification.goMessageVCNotifiction, object: nil, userInfo: userInfo)
}
func configTabBarController() -> YHTabBarViewController {
......@@ -409,5 +409,8 @@ extension YhConstant {
public static let closeShareUIInLiveRoomNotifiction = Notification.Name(rawValue: "com.yinhe.app.close.share.ui")
// 跳转到服务Tab 中的 服务进度
public static let didJumpToServiceProgressNotification = Notification.Name(rawValue: "com.yinhe.service.tab.serviceprogress")
// txIM未读消息数量变化
public static let didTxIMUnReadMsgCountChangeNotification = Notification.Name(rawValue: "com.yinhe.txIM.unReadMsgCountChange")
}
}
......@@ -768,4 +768,9 @@ class YHAllApiName {
static let getRenewalPlanGenerated = "super-app/renewal/advice/get-renewal-plan-is-generated"
}
// 腾讯IM
struct TencentIM {
// 获取用户鉴权
static let getUsersig = "super-app/tencent/im/usersig"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment