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
12b54065
Commit
12b54065
authored
Apr 17, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// 消息
parent
2d9667bd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
100 additions
and
25 deletions
+100
-25
Applegate(JPush).swift
galaxy/galaxy/Applegate(JPush).swift
+5
-5
YHMessageDetailListVC.swift
...Classes/Modules/Message(消息)/C/YHMessageDetailListVC.swift
+4
-0
YHMessageListVC.swift
...alaxy/Classes/Modules/Message(消息)/C/YHMessageListVC.swift
+68
-9
YHMyNotifySettingVC.swift
...laxy/Classes/Modules/Mine(我的)/C/YHMyNotifySettingVC.swift
+16
-11
YHMyPermissionSettingVC.swift
.../Classes/Modules/Mine(我的)/C/YHMyPermissionSettingVC.swift
+4
-0
YhConstant.swift
galaxy/galaxy/Classes/Tools/Helper/YhConstant.swift
+3
-0
No files found.
galaxy/galaxy/Applegate(JPush).swift
View file @
12b54065
...
@@ -62,11 +62,11 @@ extension AppDelegate: JPUSHRegisterDelegate {
...
@@ -62,11 +62,11 @@ extension AppDelegate: JPUSHRegisterDelegate {
}
}
//后台进前台
//后台进前台
func
application
DidEnterBack
ground
(
_
application
:
UIApplication
)
{
func
application
WillEnterFore
ground
(
_
application
:
UIApplication
)
{
//销毁通知红点
DispatchQueue
.
main
.
async
{
// UIApplication.shared.applicationIconBadgeNumber = 0
// 请求消息页面通知权限通知
// JPUSHService.setBadge(0
)
NotificationCenter
.
default
.
post
(
name
:
YhConstant
.
YhNotification
.
didReqeustNotifyPermissionNotification
,
object
:
nil
)
UNUserNotificationCenter
.
current
()
.
removeAllPendingNotificationRequests
()
}
}
}
func
jpushNotificationCenter
(
_
center
:
UNUserNotificationCenter
,
willPresent
notification
:
UNNotification
,
withCompletionHandler
completionHandler
:
((
Int
)
->
Void
))
{
func
jpushNotificationCenter
(
_
center
:
UNUserNotificationCenter
,
willPresent
notification
:
UNNotification
,
withCompletionHandler
completionHandler
:
((
Int
)
->
Void
))
{
...
...
galaxy/galaxy/Classes/Modules/Message(消息)/C/YHMessageDetailListVC.swift
View file @
12b54065
...
@@ -37,6 +37,10 @@ class YHMessageDetailListVC: YHBaseViewController {
...
@@ -37,6 +37,10 @@ class YHMessageDetailListVC: YHBaseViewController {
[
weak
self
]
in
[
weak
self
]
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
YHCommonAlertView
.
show
(
"清除未读"
,
"确定要清除所有未读提示吗?"
,
"取消"
,
"确认"
)
{
YHCommonAlertView
.
show
(
"清除未读"
,
"确定要清除所有未读提示吗?"
,
"取消"
,
"确认"
)
{
if
self
.
msgArr
.
count
<=
0
{
YHHUD
.
flash
(
message
:
"暂无消息~"
)
return
}
self
.
markAllMsgsRead
()
self
.
markAllMsgsRead
()
}
}
}
}
...
...
galaxy/galaxy/Classes/Modules/Message(消息)/C/YHMessageListVC.swift
View file @
12b54065
...
@@ -15,11 +15,11 @@ class YHMessageListVC: YHBaseViewController {
...
@@ -15,11 +15,11 @@ class YHMessageListVC: YHBaseViewController {
let
model
=
YHMsgViewModel
()
let
model
=
YHMsgViewModel
()
return
model
return
model
}()
}()
var
isNotifyEnabled
=
false
lazy
var
tableView
:
UITableView
=
{
lazy
var
tableView
:
UITableView
=
{
let
tableView
=
UITableView
(
frame
:
.
zero
,
style
:
.
grouped
)
let
tableView
=
UITableView
(
frame
:
.
zero
,
style
:
.
grouped
)
tableView
.
sectionHeaderHeight
=
42
.0
tableView
.
estimatedSectionHeaderHeight
=
1
.0
tableView
.
estimatedSectionFooterHeight
=
1.0
tableView
.
estimatedSectionFooterHeight
=
1.0
tableView
.
showsVerticalScrollIndicator
=
false
tableView
.
showsVerticalScrollIndicator
=
false
tableView
.
separatorStyle
=
.
none
tableView
.
separatorStyle
=
.
none
...
@@ -49,6 +49,10 @@ class YHMessageListVC: YHBaseViewController {
...
@@ -49,6 +49,10 @@ class YHMessageListVC: YHBaseViewController {
bar
.
rightBtnClick
=
{
bar
.
rightBtnClick
=
{
[
weak
self
]
in
[
weak
self
]
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
if
self
.
msgArr
.
count
<=
0
{
YHHUD
.
flash
(
message
:
"暂无消息~"
)
return
}
YHCommonAlertView
.
show
(
"清除未读"
,
"确定要清除所有未读提示吗?"
,
"取消"
,
"确认"
)
{
YHCommonAlertView
.
show
(
"清除未读"
,
"确定要清除所有未读提示吗?"
,
"取消"
,
"确认"
)
{
self
.
markAllMsgsRead
()
self
.
markAllMsgsRead
()
}
}
...
@@ -92,12 +96,13 @@ class YHMessageListVC: YHBaseViewController {
...
@@ -92,12 +96,13 @@ class YHMessageListVC: YHBaseViewController {
super
.
viewWillAppear
(
animated
)
super
.
viewWillAppear
(
animated
)
YHLoginManager
.
shared
.
needJumpToMsgTabFlag
=
false
YHLoginManager
.
shared
.
needJumpToMsgTabFlag
=
false
getUnreadMsgList
()
getUnreadMsgList
()
checkNotificationPermisson
()
NotificationCenter
.
default
.
post
(
name
:
YhConstant
.
YhNotification
.
didRequestUnreadMsgTotalCountNotification
,
object
:
nil
)
NotificationCenter
.
default
.
post
(
name
:
YhConstant
.
YhNotification
.
didRequestUnreadMsgTotalCountNotification
,
object
:
nil
)
}
}
func
setupUI
()
{
func
setupUI
()
{
addObservers
()
gk_navigationBar
.
isHidden
=
true
gk_navigationBar
.
isHidden
=
true
view
.
backgroundColor
=
.
white
view
.
backgroundColor
=
.
white
view
.
addSubview
(
navBar
)
view
.
addSubview
(
navBar
)
...
@@ -112,16 +117,22 @@ class YHMessageListVC: YHBaseViewController {
...
@@ -112,16 +117,22 @@ class YHMessageListVC: YHBaseViewController {
make
.
top
.
equalToSuperview
()
.
offset
(
k_Height_NavigationtBarAndStatuBar
)
make
.
top
.
equalToSuperview
()
.
offset
(
k_Height_NavigationtBarAndStatuBar
)
make
.
bottom
.
equalToSuperview
()
.
offset
(
-
k_Height_TabBar
)
make
.
bottom
.
equalToSuperview
()
.
offset
(
-
k_Height_TabBar
)
}
}
}
func
addObservers
()
{
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
)
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
getUnreadMsgList
)
,
name
:
YhConstant
.
YhNotification
.
didRequestUnreadMsgListNotification
,
object
:
nil
)
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
getUnreadMsgList
)
,
name
:
YhConstant
.
YhNotification
.
didRequestUnreadMsgListNotification
,
object
:
nil
)
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
checkNotificationPermisson
)
,
name
:
YhConstant
.
YhNotification
.
didReqeustNotifyPermissionNotification
,
object
:
nil
)
}
deinit
{
NotificationCenter
.
default
.
removeObserver
(
self
)
}
}
@objc
func
loginSuccess
()
{
@objc
func
loginSuccess
()
{
printLog
(
"登录成功,进行相应的 UI刷新操作"
)
printLog
(
"登录成功,进行相应的 UI刷新操作"
)
}
}
@objc
func
logoutSuccess
()
{
@objc
func
logoutSuccess
()
{
...
@@ -183,6 +194,42 @@ class YHMessageListVC: YHBaseViewController {
...
@@ -183,6 +194,42 @@ class YHMessageListVC: YHBaseViewController {
}
}
}
}
}
}
@objc
func
checkNotificationPermisson
()
{
checkNotificationAuthorizationStatus
{
[
weak
self
]
granted
in
guard
let
self
=
self
else
{
return
}
DispatchQueue
.
main
.
async
{
self
.
isNotifyEnabled
=
granted
self
.
tableView
.
reloadData
()
}
}
}
func
checkNotificationAuthorizationStatus
(
_
callBack
:((
Bool
)
->
())?)
{
UNUserNotificationCenter
.
current
()
.
getNotificationSettings
{
settings
in
var
enableStatus
=
false
switch
settings
.
authorizationStatus
{
case
.
authorized
:
print
(
"通知已授权"
)
enableStatus
=
true
case
.
denied
:
print
(
"通知被拒绝"
)
enableStatus
=
false
case
.
notDetermined
:
print
(
"通知权限尚未确定"
)
enableStatus
=
false
case
.
provisional
:
print
(
"通知以临时方式授权"
)
enableStatus
=
false
case
.
ephemeral
:
enableStatus
=
false
@unknown
default
:
break
}
callBack
?(
enableStatus
)
}
}
}
}
extension
YHMessageListVC
{
extension
YHMessageListVC
{
...
@@ -203,6 +250,10 @@ extension YHMessageListVC {
...
@@ -203,6 +250,10 @@ extension YHMessageListVC {
extension
YHMessageListVC
:
UITableViewDelegate
,
UITableViewDataSource
{
extension
YHMessageListVC
:
UITableViewDelegate
,
UITableViewDataSource
{
func
numberOfSections
(
in
tableView
:
UITableView
)
->
Int
{
return
1
}
func
tableView
(
_
tableView
:
UITableView
,
numberOfRowsInSection
section
:
Int
)
->
Int
{
func
tableView
(
_
tableView
:
UITableView
,
numberOfRowsInSection
section
:
Int
)
->
Int
{
return
msgArr
.
count
return
msgArr
.
count
}
}
...
@@ -233,7 +284,10 @@ extension YHMessageListVC: UITableViewDelegate, UITableViewDataSource {
...
@@ -233,7 +284,10 @@ extension YHMessageListVC: UITableViewDelegate, UITableViewDataSource {
}
}
private
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
CGFloat
{
private
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
CGFloat
{
return
42.0
if
!
isNotifyEnabled
{
return
42.0
}
return
1.0
}
}
private
func
tableView
(
_
tableView
:
UITableView
,
viewForFooterInSection
section
:
Int
)
->
CGFloat
{
private
func
tableView
(
_
tableView
:
UITableView
,
viewForFooterInSection
section
:
Int
)
->
CGFloat
{
...
@@ -247,6 +301,10 @@ extension YHMessageListVC: UITableViewDelegate, UITableViewDataSource {
...
@@ -247,6 +301,10 @@ extension YHMessageListVC: UITableViewDelegate, UITableViewDataSource {
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
UIView
?
{
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
UIView
?
{
if
isNotifyEnabled
{
return
UIView
()
}
let
view
=
UIView
()
let
view
=
UIView
()
view
.
backgroundColor
=
UIColor
(
hex
:
0x3570DC
,
alpha
:
0.06
)
view
.
backgroundColor
=
UIColor
(
hex
:
0x3570DC
,
alpha
:
0.06
)
...
@@ -270,10 +328,11 @@ extension YHMessageListVC: UITableViewDelegate, UITableViewDataSource {
...
@@ -270,10 +328,11 @@ extension YHMessageListVC: UITableViewDelegate, UITableViewDataSource {
make
.
right
.
equalTo
(
enableBtn
.
snp
.
left
)
.
offset
(
-
20
)
make
.
right
.
equalTo
(
enableBtn
.
snp
.
left
)
.
offset
(
-
20
)
make
.
centerY
.
equalToSuperview
()
make
.
centerY
.
equalToSuperview
()
}
}
enableBtn
.
snp
.
makeConstraints
{
make
in
enableBtn
.
snp
.
makeConstraints
{
make
in
make
.
size
.
equalTo
(
CGSize
(
width
:
26
,
height
:
18
))
make
.
size
.
equalTo
(
CGSize
(
width
:
26
,
height
:
42.0
))
make
.
right
.
equalToSuperview
()
.
offset
(
-
20
)
make
.
right
.
equalToSuperview
()
.
offset
(
-
20
)
make
.
centerY
.
equalToSuperview
()
make
.
top
.
bottom
.
equalToSuperview
()
}
}
return
view
return
view
}
}
...
...
galaxy/galaxy/Classes/Modules/Mine(我的)/C/YHMyNotifySettingVC.swift
View file @
12b54065
...
@@ -32,6 +32,22 @@ class YHMyNotifySettingVC: YHBaseViewController {
...
@@ -32,6 +32,22 @@ class YHMyNotifySettingVC: YHBaseViewController {
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
super
.
viewWillAppear
(
animated
)
checkNotifyPermission
()
}
func
setupUI
()
{
gk_navTitle
=
"通知设置"
.
local
view
.
backgroundColor
=
.
white
view
.
addSubview
(
tableView
)
tableView
.
snp
.
makeConstraints
{
make
in
make
.
left
.
right
.
equalToSuperview
()
make
.
top
.
equalToSuperview
()
.
offset
(
k_Height_NavigationtBarAndStatuBar
)
make
.
bottom
.
equalToSuperview
()
.
offset
(
-
k_Height_TabBar
)
}
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
checkNotifyPermission
)
,
name
:
YhConstant
.
YhNotification
.
didReqeustNotifyPermissionNotification
,
object
:
nil
)
}
@objc
func
checkNotifyPermission
()
{
checkNotificationAuthorizationStatus
{
checkNotificationAuthorizationStatus
{
[
weak
self
]
granted
in
[
weak
self
]
granted
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
...
@@ -46,17 +62,6 @@ class YHMyNotifySettingVC: YHBaseViewController {
...
@@ -46,17 +62,6 @@ class YHMyNotifySettingVC: YHBaseViewController {
}
}
}
}
func
setupUI
()
{
gk_navTitle
=
"通知设置"
.
local
view
.
backgroundColor
=
.
white
view
.
addSubview
(
tableView
)
tableView
.
snp
.
makeConstraints
{
make
in
make
.
left
.
right
.
equalToSuperview
()
make
.
top
.
equalToSuperview
()
.
offset
(
k_Height_NavigationtBarAndStatuBar
)
make
.
bottom
.
equalToSuperview
()
.
offset
(
-
k_Height_TabBar
)
}
}
func
checkNotificationAuthorizationStatus
(
_
callBack
:((
Bool
)
->
())?)
{
func
checkNotificationAuthorizationStatus
(
_
callBack
:((
Bool
)
->
())?)
{
UNUserNotificationCenter
.
current
()
.
getNotificationSettings
{
settings
in
UNUserNotificationCenter
.
current
()
.
getNotificationSettings
{
settings
in
var
enableStatus
=
false
var
enableStatus
=
false
...
...
galaxy/galaxy/Classes/Modules/Mine(我的)/C/YHMyPermissionSettingVC.swift
View file @
12b54065
...
@@ -137,6 +137,10 @@ class YHMyPermissionSettingVC: YHBaseViewController {
...
@@ -137,6 +137,10 @@ class YHMyPermissionSettingVC: YHBaseViewController {
completion
(
false
)
completion
(
false
)
}
}
}
}
deinit
{
NotificationCenter
.
default
.
removeObserver
(
self
)
}
}
}
extension
YHMyPermissionSettingVC
:
UITableViewDelegate
,
UITableViewDataSource
{
extension
YHMyPermissionSettingVC
:
UITableViewDelegate
,
UITableViewDataSource
{
...
...
galaxy/galaxy/Classes/Tools/Helper/YhConstant.swift
View file @
12b54065
...
@@ -205,5 +205,8 @@ extension YhConstant {
...
@@ -205,5 +205,8 @@ extension YhConstant {
// 请求消息未读列表通知
// 请求消息未读列表通知
public
static
let
didRequestUnreadMsgListNotification
=
Notification
.
Name
(
rawValue
:
"com.yinhe.msgPage.unreadList"
)
public
static
let
didRequestUnreadMsgListNotification
=
Notification
.
Name
(
rawValue
:
"com.yinhe.msgPage.unreadList"
)
// 请求通知权限通知
public
static
let
didReqeustNotifyPermissionNotification
=
Notification
.
Name
(
rawValue
:
"com.yinhe.msgPage.notifyPermission"
)
}
}
}
}
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