Commit 2d9667bd authored by Steven杜宇's avatar Steven杜宇

// 消息

parent 7e6b0894
...@@ -77,6 +77,13 @@ extension AppDelegate: JPUSHRegisterDelegate { ...@@ -77,6 +77,13 @@ extension AppDelegate: JPUSHRegisterDelegate {
} }
// 需要执行这个方法,选择是否提醒用户,有Badge、Sound、Alert三种类型可以选择设置 // 需要执行这个方法,选择是否提醒用户,有Badge、Sound、Alert三种类型可以选择设置
completionHandler(Int(UNNotificationPresentationOptions.alert.rawValue)) completionHandler(Int(UNNotificationPresentationOptions.alert.rawValue))
// 显示通知时需要刷新消息列表和消息未读总数
DispatchQueue.main.async {
// 请求消息未读总数通知
NotificationCenter.default.post(name: YhConstant.YhNotification.didRequestUnreadMsgTotalCountNotification, object: nil)
// 请求消息列表通知
NotificationCenter.default.post(name: YhConstant.YhNotification.didRequestUnreadMsgListNotification, object: nil)
}
} }
func jpushNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: (() -> Void)) { func jpushNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: (() -> Void)) {
......
...@@ -93,7 +93,7 @@ class YHMessageListVC: YHBaseViewController { ...@@ -93,7 +93,7 @@ class YHMessageListVC: YHBaseViewController {
YHLoginManager.shared.needJumpToMsgTabFlag = false YHLoginManager.shared.needJumpToMsgTabFlag = false
getUnreadMsgList() getUnreadMsgList()
NotificationCenter.default.post(name: YhConstant.YhNotification.didRequestUnreadMsgTotalCountNotification, object: nil) NotificationCenter.default.post(name: YhConstant.YhNotification.didRequestUnreadMsgTotalCountNotification, object: nil)
} }
func setupUI() { func setupUI() {
...@@ -115,6 +115,7 @@ class YHMessageListVC: YHBaseViewController { ...@@ -115,6 +115,7 @@ class YHMessageListVC: YHBaseViewController {
NotificationCenter.default.addObserver(self, selector: #selector(loginSuccess), name: YhConstant.YhNotification.didLoginSuccessNotifiction, object: nil) 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(logoutSuccess), name: YhConstant.YhNotification.didLogoutSuccessNotifiction, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(getUnreadMsgList), name: YhConstant.YhNotification.didRequestUnreadMsgListNotification, object: nil)
} }
...@@ -127,7 +128,7 @@ class YHMessageListVC: YHBaseViewController { ...@@ -127,7 +128,7 @@ class YHMessageListVC: YHBaseViewController {
} }
func getUnreadMsgList() { @objc func getUnreadMsgList() {
self.viewModel.getUnreadMsgList { self.viewModel.getUnreadMsgList {
[weak self] success, error in [weak self] success, error in
guard let self = self else { return } guard let self = self else { return }
......
...@@ -202,5 +202,8 @@ extension YhConstant { ...@@ -202,5 +202,8 @@ extension YhConstant {
// 请求消息未读总数通知 // 请求消息未读总数通知
public static let didRequestUnreadMsgTotalCountNotification = Notification.Name(rawValue: "com.yinhe.msgPage.unreadMsgTotal") public static let didRequestUnreadMsgTotalCountNotification = Notification.Name(rawValue: "com.yinhe.msgPage.unreadMsgTotal")
// 请求消息未读列表通知
public static let didRequestUnreadMsgListNotification = Notification.Name(rawValue: "com.yinhe.msgPage.unreadList")
} }
} }
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