Commit 0feaa40d authored by Alex朱枝文's avatar Alex朱枝文

增加模型文件以及通知log日志处理

parent 36383ed2
...@@ -468,6 +468,7 @@ ...@@ -468,6 +468,7 @@
04B360F52C646844001EB053 /* YHPrincipleApprovedMailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B360F42C646844001EB053 /* YHPrincipleApprovedMailViewController.swift */; }; 04B360F52C646844001EB053 /* YHPrincipleApprovedMailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B360F42C646844001EB053 /* YHPrincipleApprovedMailViewController.swift */; };
04B360F72C646B4F001EB053 /* YHPrincipleEnvelopeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B360F62C646B4F001EB053 /* YHPrincipleEnvelopeModel.swift */; }; 04B360F72C646B4F001EB053 /* YHPrincipleEnvelopeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B360F62C646B4F001EB053 /* YHPrincipleEnvelopeModel.swift */; };
04B4B8D52C89CE5E00ED82BC /* YHButlerServiceMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B4B8D42C89CE5E00ED82BC /* YHButlerServiceMessage.swift */; }; 04B4B8D52C89CE5E00ED82BC /* YHButlerServiceMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B4B8D42C89CE5E00ED82BC /* YHButlerServiceMessage.swift */; };
04B4B8D72C8AE77C00ED82BC /* YHYHButlerServiceMessageHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B4B8D62C8AE77C00ED82BC /* YHYHButlerServiceMessageHandler.swift */; };
04B9EE5A2C06CC3100A4018D /* YHCodeSueecssViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B9EE582C06CC3100A4018D /* YHCodeSueecssViewController.swift */; }; 04B9EE5A2C06CC3100A4018D /* YHCodeSueecssViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B9EE582C06CC3100A4018D /* YHCodeSueecssViewController.swift */; };
04B9EE5B2C06CC3100A4018D /* YHOtherLoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B9EE592C06CC3100A4018D /* YHOtherLoginViewController.swift */; }; 04B9EE5B2C06CC3100A4018D /* YHOtherLoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B9EE592C06CC3100A4018D /* YHOtherLoginViewController.swift */; };
04C693622B723AB8004C1758 /* YHMySettingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C693612B723AB8004C1758 /* YHMySettingViewController.swift */; }; 04C693622B723AB8004C1758 /* YHMySettingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C693612B723AB8004C1758 /* YHMySettingViewController.swift */; };
...@@ -1249,6 +1250,7 @@ ...@@ -1249,6 +1250,7 @@
04B360F42C646844001EB053 /* YHPrincipleApprovedMailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPrincipleApprovedMailViewController.swift; sourceTree = "<group>"; }; 04B360F42C646844001EB053 /* YHPrincipleApprovedMailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPrincipleApprovedMailViewController.swift; sourceTree = "<group>"; };
04B360F62C646B4F001EB053 /* YHPrincipleEnvelopeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPrincipleEnvelopeModel.swift; sourceTree = "<group>"; }; 04B360F62C646B4F001EB053 /* YHPrincipleEnvelopeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPrincipleEnvelopeModel.swift; sourceTree = "<group>"; };
04B4B8D42C89CE5E00ED82BC /* YHButlerServiceMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHButlerServiceMessage.swift; sourceTree = "<group>"; }; 04B4B8D42C89CE5E00ED82BC /* YHButlerServiceMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHButlerServiceMessage.swift; sourceTree = "<group>"; };
04B4B8D62C8AE77C00ED82BC /* YHYHButlerServiceMessageHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHYHButlerServiceMessageHandler.swift; sourceTree = "<group>"; };
04B9EE582C06CC3100A4018D /* YHCodeSueecssViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHCodeSueecssViewController.swift; sourceTree = "<group>"; }; 04B9EE582C06CC3100A4018D /* YHCodeSueecssViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHCodeSueecssViewController.swift; sourceTree = "<group>"; };
04B9EE592C06CC3100A4018D /* YHOtherLoginViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHOtherLoginViewController.swift; sourceTree = "<group>"; }; 04B9EE592C06CC3100A4018D /* YHOtherLoginViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHOtherLoginViewController.swift; sourceTree = "<group>"; };
04C693612B723AB8004C1758 /* YHMySettingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMySettingViewController.swift; sourceTree = "<group>"; }; 04C693612B723AB8004C1758 /* YHMySettingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMySettingViewController.swift; sourceTree = "<group>"; };
...@@ -1582,6 +1584,7 @@ ...@@ -1582,6 +1584,7 @@
04B4B8D32C89CCE400ED82BC /* M */, 04B4B8D32C89CCE400ED82BC /* M */,
0414708C2C895A1800B7B688 /* VM */, 0414708C2C895A1800B7B688 /* VM */,
0414708A2C88627B00B7B688 /* YHButlerServiceManager.swift */, 0414708A2C88627B00B7B688 /* YHButlerServiceManager.swift */,
04B4B8D62C8AE77C00ED82BC /* YHYHButlerServiceMessageHandler.swift */,
); );
path = "ButlerServiceManager(银河管家)"; path = "ButlerServiceManager(银河管家)";
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -4314,23 +4317,6 @@ ...@@ -4314,23 +4317,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0; showEnvVarsInLog = 0;
}; };
F9A2927DE3EDC6863D0D1B1D /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-galaxy/Pods-galaxy-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-galaxy/Pods-galaxy-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-galaxy/Pods-galaxy-resources.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */ /* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */
...@@ -4400,6 +4386,7 @@ ...@@ -4400,6 +4386,7 @@
A58AC09D2BABD59600A30FA9 /* YHFileListModel.swift in Sources */, A58AC09D2BABD59600A30FA9 /* YHFileListModel.swift in Sources */,
045EEEFF2B9F171A0022A143 /* YHSaveAndSubmitView.swift in Sources */, 045EEEFF2B9F171A0022A143 /* YHSaveAndSubmitView.swift in Sources */,
045EEF0E2B9F171A0022A143 /* YHBasicInfoFillView.swift in Sources */, 045EEF0E2B9F171A0022A143 /* YHBasicInfoFillView.swift in Sources */,
04B4B8D72C8AE77C00ED82BC /* YHYHButlerServiceMessageHandler.swift in Sources */,
04AF514E2BEB585C00009E3A /* YHVideoPlayerVC.swift in Sources */, 04AF514E2BEB585C00009E3A /* YHVideoPlayerVC.swift in Sources */,
04CE1ADA2C2AD91F001CB80A /* YHActivityTravelitemView.swift in Sources */, 04CE1ADA2C2AD91F001CB80A /* YHActivityTravelitemView.swift in Sources */,
045EEEA12B9F171A0022A143 /* YHWorkExperienceDetailModel.swift in Sources */, 045EEEA12B9F171A0022A143 /* YHWorkExperienceDetailModel.swift in Sources */,
......
...@@ -8,14 +8,15 @@ ...@@ -8,14 +8,15 @@
import UIKit import UIKit
// Mark: - 管家消息简单模型 // MARK: - 管家消息简单模型
class YHButlerServiceMessage: NSObject { class YHButlerServiceMessage: NSObject {
var id: String = "" var id: String = ""
var content: String = "" var content: String = ""
var isRead: Bool = true var isRead: Bool = true
var timeStamp: TimeInterval = 0
} }
// Mark: - 用于首页显示与否 // MARK: - 用于首页显示与否
class YHButlerServiceHomeInfoMessage: YHButlerServiceMessage { class YHButlerServiceHomeInfoMessage: YHButlerServiceMessage {
var showButler: Bool = false var showButler: Bool = false
} }
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
import UIKit import UIKit
import IQKeyboardManagerSwift import IQKeyboardManagerSwift
import OSLog
class YHButlerServiceManager: NSObject { class YHButlerServiceManager: NSObject {
...@@ -17,6 +18,9 @@ class YHButlerServiceManager: NSObject { ...@@ -17,6 +18,9 @@ class YHButlerServiceManager: NSObject {
private lazy var getUserInfoViewModel: YHButlerServiceViewModel = YHButlerServiceViewModel() private lazy var getUserInfoViewModel: YHButlerServiceViewModel = YHButlerServiceViewModel()
var lastMessage: YHButlerServiceMessage?
var unreadCount: Int = 0
private override init() { private override init() {
super.init() super.init()
conversationManager?.setDelegate(self) conversationManager?.setDelegate(self)
...@@ -29,6 +33,15 @@ class YHButlerServiceManager: NSObject { ...@@ -29,6 +33,15 @@ class YHButlerServiceManager: NSObject {
let qyOption = QYSDKOption(appKey: YhConstant.QiYuSDK.appKey) let qyOption = QYSDKOption(appKey: YhConstant.QiYuSDK.appKey)
qyOption.appName = YhConstant.QiYuSDK.appName qyOption.appName = YhConstant.QiYuSDK.appName
QYSDK.shared().register(with: qyOption) QYSDK.shared().register(with: qyOption)
lastMessage = getLastMessage()
}
/// 必须在初始化后调用
func getLastMessage() -> YHButlerServiceMessage? {
guard let message = getSessionList().first else {
return nil
}
return YHYHButlerServiceMessageHandler.handleSessionMessage(sessionMessage: message)
} }
func updateUserInfo(userId: String, userData: String, completion: @escaping (Bool) -> Void) { func updateUserInfo(userId: String, userData: String, completion: @escaping (Bool) -> Void) {
...@@ -38,7 +51,6 @@ class YHButlerServiceManager: NSObject { ...@@ -38,7 +51,6 @@ class YHButlerServiceManager: NSObject {
QYSDK.shared().setUserInfo(userInfo) { success, error in QYSDK.shared().setUserInfo(userInfo) { success, error in
completion(success) completion(success)
} }
} }
func updateApnsToken(token: Data) { func updateApnsToken(token: Data) {
...@@ -117,17 +129,25 @@ extension YHButlerServiceManager { ...@@ -117,17 +129,25 @@ extension YHButlerServiceManager {
/// 获取所有会话的列表;非平台电商用户,只有一个会话项,平台电商用户,有多个会话项 /// 获取所有会话的列表;非平台电商用户,只有一个会话项,平台电商用户,有多个会话项
func getSessionList() -> [QYSessionInfo] { func getSessionList() -> [QYSessionInfo] {
return conversationManager?.getSessionList() ?? [] let list = conversationManager?.getSessionList() ?? []
os_log("#####getSessionList %@", (list.first?.description ?? ""))
printLog("$$$$getSessionList \(list.first?.lastMessageText ?? "") \(list.first?.lastMessageType.rawValue ?? 0) \(list.first?.lastMessageTimeStamp ?? 0)")
return list
} }
/// 所有的未读数 /// 所有的未读数
func allUnreadCount() -> Int { func allUnreadCount() -> Int {
return conversationManager?.allUnreadCount() ?? 0 let count = conversationManager?.allUnreadCount() ?? 0
os_log("#####allUnreadCount %ld", count)
printLog("$$$$allUnreadCount \(count)")
return count
} }
/// 清空未读数 /// 清空未读数
func clearUnreadCount() { func clearUnreadCount() {
conversationManager?.clearUnreadCount() conversationManager?.clearUnreadCount()
printLog("$$$$clearUnreadCount")
os_log("#####clearUnreadCount")
} }
} }
...@@ -135,18 +155,28 @@ extension YHButlerServiceManager { ...@@ -135,18 +155,28 @@ extension YHButlerServiceManager {
extension YHButlerServiceManager: QYConversationManagerDelegate { extension YHButlerServiceManager: QYConversationManagerDelegate {
// MARK: - QYConversationManagerDelegate // MARK: - QYConversationManagerDelegate
/// 会话列表变化;非平台电商用户,只有一个会话项,平台电商用户,有多个会话项 /// 会话列表变化;非平台电商用户,只有一个会话项,平台电商用户,有多个会话项 用这个方法可以拿到最新的完整的消息内容
func onSessionListChanged(_ sessionList: [QYSessionInfo]!) { func onSessionListChanged(_ sessionList: [QYSessionInfo]!) {
// printLog("$$$$onSessionListChanged \(sessionList.first?.lastMessageText ?? "") \(sessionList.first?.lastMessageType.rawValue ?? 0) \(sessionList.first?.lastMessageTimeStamp ?? 0) \(sessionList.first?.lastMessage?.messageId ?? "")")
os_log("#####onSessionListChanged %@ %d", sessionList.first?.lastMessageText ?? "")
guard let message = sessionList.first else {
return
}
lastMessage = YHYHButlerServiceMessageHandler.handleSessionMessage(sessionMessage: message)
NotificationCenter.default.post(name: YhConstant.YhNotification.didQiYuReceiveNewMsgNotification, object: nil)
} }
/// 接收消息 /// 接收消息(进聊天页面会刷新, 目前不用这个方法打点记录)
func onReceiveMessage(_ message: QYMessageInfo!) { func onReceiveMessage(_ message: QYMessageInfo!) {
// printLog("$$$$onReceiveMessage \(message?.text ?? "") \(message?.type.rawValue ?? 0) \(message?.timeStamp ?? 0)")
os_log("#####onReceiveMessage %@ %ld", (message?.text ?? ""))
} }
/// 会话未读数变化 /// 会话未读数变化(进聊天页面会刷新)
func onUnreadCountChanged(_ count: Int) { func onUnreadCountChanged(_ count: Int) {
// printLog("$$$$onUnreadCountChanged \(count)")
os_log("#####onUnreadCountChanged %ld", count)
unreadCount = count
NotificationCenter.default.post(name: YhConstant.YhNotification.didQiYuUnReadMsgCountChangeNotification, object: nil)
} }
} }
//
// YHYHButlerServiceMessageHandler.swift
// galaxy
//
// Created by alexzzw on 2024/9/6.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHYHButlerServiceMessageHandler: NSObject {
// MARK: - 七鱼消息处理
/// 七鱼消息转成银河需要的类型
static func handleSessionMessage(sessionMessage: QYSessionInfo) -> YHButlerServiceMessage {
// 列表: 暂无消息
// 首页: 您有一条新的消息
let nimMessage = sessionMessage.lastMessage // 网易云信消息
let retMessage = YHButlerServiceMessage()
retMessage.content = getContent(type: sessionMessage.lastMessageType, originalText: sessionMessage.lastMessageText, nimMessage: nimMessage) ?? ""
retMessage.id = nimMessage?.messageId ?? ""
retMessage.timeStamp = sessionMessage.lastMessageTimeStamp
retMessage.isRead = nimMessage?.status == .read
return retMessage
}
}
extension YHYHButlerServiceMessageHandler {
// MARK: - 私有方法
/// 消息内容简单处理
static private func getContent(type: QYMessageType, originalText: String?, nimMessage: NIMMessage?) -> String? {
var text: String = ""
switch type {
case .audio:
text = "[语音]"
if let audioMessage = nimMessage?.messageObject as? NIMAudioObject {
let duration = audioMessage.duration
if duration > 0 {
let seconds = (duration + 999) / 1000
text += "\(seconds)″"
}
}
case .text:
text = originalText ?? ""
case .image:
text = "[图片]"
case .video:
text = "[视频]"
case .file:
text = "[文件]"
case .custom:
text = originalText ?? ""
@unknown default:
text = originalText ?? ""
}
return text
}
}
...@@ -277,6 +277,12 @@ extension YhConstant { ...@@ -277,6 +277,12 @@ extension YhConstant {
// 改变底部tabbar上 分享View的展示状态 // 改变底部tabbar上 分享View的展示状态
public static let changeShareViewStatusOnTabBarNotifiction = Notification.Name(rawValue: "com.yinhe.change.shareView.status") public static let changeShareViewStatusOnTabBarNotifiction = Notification.Name(rawValue: "com.yinhe.change.shareView.status")
// 七鱼有新消息
public static let didQiYuReceiveNewMsgNotification = Notification.Name(rawValue: "com.yinhe.qiyu.receiveNewMsg")
// 七鱼未读消息数量变化
public static let didQiYuUnReadMsgCountChangeNotification = Notification.Name(rawValue: "com.yinhe.qiyu.unReadMsgCountChange")
//获取灰度参数 //获取灰度参数
public static let didRevUatParam = Notification.Name(rawValue: "com.yinhe.didRevUatParam") public static let didRevUatParam = Notification.Name(rawValue: "com.yinhe.didRevUatParam")
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#import "TYSnapshotScroll.h" #import "TYSnapshotScroll.h"
// 七鱼SDK // 七鱼SDK
#import <QYSDK/QYSDK.h> #import <QYSDK/QYSDK.h>
#import <NIMSDK/NIMMessage.h>
#endif #endif
......
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