Commit 487a7826 authored by David黄金龙's avatar David黄金龙

点击推送 跳转 消息列表

parent f140bcff
...@@ -52,8 +52,9 @@ extension AppDelegate: JPUSHRegisterDelegate { ...@@ -52,8 +52,9 @@ extension AppDelegate: JPUSHRegisterDelegate {
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
JPUSHService.handleRemoteNotification(userInfo) JPUSHService.handleRemoteNotification(userInfo)
completionHandler(UIBackgroundFetchResult.newData) completionHandler(UIBackgroundFetchResult.newData)
// 转换到消息tab // 转换到消息tab
NotificationCenter.default.post(name: YhConstant.YhNotification.didSwithToMsgTabNotification, object: nil) YHLoginManager.shared.needJumpToMsgTabFlag = true
} }
...@@ -82,8 +83,10 @@ extension AppDelegate: JPUSHRegisterDelegate { ...@@ -82,8 +83,10 @@ extension AppDelegate: JPUSHRegisterDelegate {
} }
// 系统要求执行这个方法 // 系统要求执行这个方法
completionHandler() completionHandler()
// 转换到消息tab // 转换到消息tab
NotificationCenter.default.post(name: YhConstant.YhNotification.didSwithToMsgTabNotification, object: nil)
YHLoginManager.shared.needJumpToMsgTabFlag = true
} }
......
...@@ -29,7 +29,6 @@ class YHTabBarViewController: ESTabBarController { ...@@ -29,7 +29,6 @@ class YHTabBarViewController: ESTabBarController {
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(clearAllUnreadMsg), name: YhConstant.YhNotification.didMarkAllMessagesReadedNotifiction, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(clearAllUnreadMsg), name: YhConstant.YhNotification.didMarkAllMessagesReadedNotifiction, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(switchToMsgTab), name: YhConstant.YhNotification.didSwithToMsgTabNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(getTotalUnreadMsgCount), name: YhConstant.YhNotification.didRequestUnreadMsgTotalCountNotification, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(getTotalUnreadMsgCount), name: YhConstant.YhNotification.didRequestUnreadMsgTotalCountNotification, object: nil)
} }
...@@ -53,12 +52,6 @@ extension YHTabBarViewController { ...@@ -53,12 +52,6 @@ extension YHTabBarViewController {
printLog("登出成功") printLog("登出成功")
} }
// 转换到消息tab
@objc func switchToMsgTab() {
DispatchQueue.main.asyncAfter(deadline: .now() + 8) {
goTabBarBy(tabType: .message)
}
}
@objc func clearAllUnreadMsg() { @objc func clearAllUnreadMsg() {
DispatchQueue.main.async { DispatchQueue.main.async {
......
...@@ -173,5 +173,13 @@ private extension YHStartPageViewController { ...@@ -173,5 +173,13 @@ private extension YHStartPageViewController {
let window = UIApplication.shared.yhKeyWindow() let window = UIApplication.shared.yhKeyWindow()
window?.rootViewController = tabBarController window?.rootViewController = tabBarController
window?.makeKeyAndVisible() window?.makeKeyAndVisible()
YHLoginManager.shared.needJumpToMsgTabFlag = true //for test hjl
if YHLoginManager.shared.needJumpToMsgTabFlag {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25, execute: {
goTabBarBy(tabType: .message)
})
}
} }
} }
...@@ -20,6 +20,10 @@ class YHLoginManager: NSObject { ...@@ -20,6 +20,10 @@ class YHLoginManager: NSObject {
private override init() {} private override init() {}
var needJumpToMsgTabFlag : Bool = false
}
extension YHLoginManager {
func isLogin() -> Bool { func isLogin() -> Bool {
let ttt = userModel?.token?.count ?? 0 let ttt = userModel?.token?.count ?? 0
if ttt != 0 { if ttt != 0 {
......
...@@ -90,6 +90,7 @@ class YHMessageListVC: YHBaseViewController { ...@@ -90,6 +90,7 @@ class YHMessageListVC: YHBaseViewController {
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated) super.viewWillAppear(animated)
YHLoginManager.shared.needJumpToMsgTabFlag = false
getUnreadMsgList() getUnreadMsgList()
NotificationCenter.default.post(name: YhConstant.YhNotification.didRequestUnreadMsgTotalCountNotification, object: nil) NotificationCenter.default.post(name: YhConstant.YhNotification.didRequestUnreadMsgTotalCountNotification, object: nil)
......
...@@ -200,9 +200,6 @@ extension YhConstant { ...@@ -200,9 +200,6 @@ extension YhConstant {
//清空所有未读消息数 //清空所有未读消息数
public static let didMarkAllMessagesReadedNotifiction = Notification.Name(rawValue: "com.yinhe.msgPage.readAll") public static let didMarkAllMessagesReadedNotifiction = Notification.Name(rawValue: "com.yinhe.msgPage.readAll")
// 自动转换到消息tab
public static let didSwithToMsgTabNotification = Notification.Name(rawValue: "com.yinhe.msgPage.switch")
// 请求消息未读总数通知 // 请求消息未读总数通知
public static let didRequestUnreadMsgTotalCountNotification = Notification.Name(rawValue: "com.yinhe.msgPage.unreadMsgTotal") public static let didRequestUnreadMsgTotalCountNotification = Notification.Name(rawValue: "com.yinhe.msgPage.unreadMsgTotal")
} }
......
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