Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
galaxy-iOS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mobile-group
galaxy-iOS
Commits
cfd3df0b
Commit
cfd3df0b
authored
Apr 16, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// 消息
parent
15d3edc3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
14 deletions
+38
-14
Applegate(JPush).swift
galaxy/galaxy/Applegate(JPush).swift
+5
-2
YHTabBarViewController.swift
galaxy/galaxy/Classes/Base/C/YHTabBarViewController.swift
+30
-12
YhConstant.swift
galaxy/galaxy/Classes/Tools/Helper/YhConstant.swift
+3
-0
No files found.
galaxy/galaxy/Applegate(JPush).swift
View file @
cfd3df0b
...
...
@@ -52,13 +52,16 @@ extension AppDelegate: JPUSHRegisterDelegate {
func
application
(
_
application
:
UIApplication
,
didReceiveRemoteNotification
userInfo
:
[
AnyHashable
:
Any
],
fetchCompletionHandler
completionHandler
:
@escaping
(
UIBackgroundFetchResult
)
->
Void
)
{
JPUSHService
.
handleRemoteNotification
(
userInfo
)
completionHandler
(
UIBackgroundFetchResult
.
newData
)
// 转换到消息tab
NotificationCenter
.
default
.
post
(
name
:
YhConstant
.
YhNotification
.
didSwithToMsgTabNotification
,
object
:
nil
)
}
//后台进前台
func
applicationDidEnterBackground
(
_
application
:
UIApplication
)
{
//销毁通知红点
UIApplication
.
shared
.
applicationIconBadgeNumber
=
0
JPUSHService
.
setBadge
(
0
)
//
UIApplication.shared.applicationIconBadgeNumber = 0
//
JPUSHService.setBadge(0)
UNUserNotificationCenter
.
current
()
.
removeAllPendingNotificationRequests
()
}
...
...
galaxy/galaxy/Classes/Base/C/YHTabBarViewController.swift
View file @
cfd3df0b
...
...
@@ -20,12 +20,14 @@ class YHTabBarViewController: ESTabBarController {
super
.
viewDidLoad
()
handleTabBarLine
()
addObservers
()
self
.
delegate
=
self
}
func
addObservers
()
{
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(
clearAllUnreadMsg
)
,
name
:
YhConstant
.
YhNotification
.
didMarkAllMessagesReadedNotifiction
,
object
:
nil
)
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
switchToMsgTab
)
,
name
:
YhConstant
.
YhNotification
.
didSwithToMsgTabNotification
,
object
:
nil
)
}
}
...
...
@@ -48,6 +50,22 @@ extension YHTabBarViewController {
printLog
(
"登出成功"
)
}
// 转换到消息tab
@objc
func
switchToMsgTab
()
{
DispatchQueue
.
main
.
async
{
self
.
selectedIndex
=
2
}
}
@objc
func
clearAllUnreadMsg
()
{
DispatchQueue
.
main
.
async
{
if
let
vcs
=
self
.
viewControllers
,
let
msgListVC
=
vcs
[
safe
:
2
]
{
msgListVC
.
tabBarItem
.
badgeValue
=
""
UIApplication
.
shared
.
applicationIconBadgeNumber
=
0
}
}
}
func
getTotalUnreadMsgCount
()
{
self
.
viewModel
.
requestTotalUnreadMsgCount
{
[
weak
self
]
success
,
error
in
...
...
@@ -55,27 +73,17 @@ extension YHTabBarViewController {
DispatchQueue
.
main
.
async
{
if
let
vcs
=
self
.
viewControllers
,
let
msgListVC
=
vcs
[
safe
:
2
]
{
var
count
=
self
.
viewModel
.
unreadTotalCount
let
count
=
self
.
viewModel
.
unreadTotalCount
var
unreadText
=
String
(
count
)
if
count
>
99
{
unreadText
=
"99+"
}
msgListVC
.
tabBarItem
.
badgeValue
=
unreadText
UIApplication
.
shared
.
applicationIconBadgeNumber
=
count
}
}
}
}
@objc
func
clearAllUnreadMsg
()
{
DispatchQueue
.
main
.
async
{
if
let
vcs
=
self
.
viewControllers
,
let
msgListVC
=
vcs
[
safe
:
2
]
{
msgListVC
.
tabBarItem
.
badgeValue
=
""
UIApplication
.
shared
.
applicationIconBadgeNumber
=
0
}
}
}
}
extension
YHTabBarViewController
{
...
...
@@ -94,6 +102,16 @@ extension YHTabBarViewController {
}
completion
:
{
Bool
in
}
}
}
extension
YHTabBarViewController
:
UITabBarControllerDelegate
{
func
tabBarController
(
_
tabBarController
:
UITabBarController
,
didSelect
viewController
:
UIViewController
)
{
if
let
vcs
=
self
.
viewControllers
,
let
msgVC
=
vcs
[
safe
:
2
],
viewController
==
msgVC
{
// 点击消息tab 清空应用icon未读数
UIApplication
.
shared
.
applicationIconBadgeNumber
=
8
}
}
}
galaxy/galaxy/Classes/Tools/Helper/YhConstant.swift
View file @
cfd3df0b
...
...
@@ -199,5 +199,8 @@ extension YhConstant {
//清空所有未读消息数
public
static
let
didMarkAllMessagesReadedNotifiction
=
Notification
.
Name
(
rawValue
:
"com.yinhe.msgPage.readAll"
)
// 自动转换到消息tab
public
static
let
didSwithToMsgTabNotification
=
Notification
.
Name
(
rawValue
:
"com.yinhe.msgPage.switch"
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment