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
92d9087e
Commit
92d9087e
authored
Apr 19, 2024
by
David黄金龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
推送相关的bug
parent
9209ab13
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
13 deletions
+35
-13
Applegate(JPush).swift
galaxy/galaxy/Applegate(JPush).swift
+35
-13
No files found.
galaxy/galaxy/Applegate(JPush).swift
View file @
92d9087e
...
...
@@ -24,15 +24,21 @@ extension AppDelegate: JPUSHRegisterDelegate {
// init Push
// notice: 2.1.5 版本的 SDK 新增的注册方法,改成可上报 IDFA,如果没有使用 IDFA 直接传 nil
//初始化极光推送服务,调用了本 API 后,开启 JPush 推送服务,将会开始收集上报 SDK 业务功能所必要的用户个人信息
// [JPUSHService setupWithOption:launchOptions appKey:appKey
// channel:channel
// apsForProduction:isProduction
// advertisingIdentifier:advertisingId];
// [JPUSHService setupWithOption:launchOptions appKey:appKey
// channel:channel
// apsForProduction:isProduction
// advertisingIdentifier:advertisingId];
#if DEBUG
let
isProduction
=
false
#elseif TESTENV
let
isProduction
=
true
#else
let
isProduction
=
true
#endif
JPUSHService
.
setup
(
withOption
:
launchOptions
,
appKey
:
"c6a9e10575b85ee90f3e8afe"
,
channel
:
""
,
channel
:
"
appStore
"
,
apsForProduction
:
isProduction
)
}
...
...
@@ -42,23 +48,39 @@ extension AppDelegate: JPUSHRegisterDelegate {
print
(
"deviceToken:
\(
deviceTokenStr
)
"
)
JPUSHService
.
registerDeviceToken
(
deviceToken
)
YHLoginManager
.
shared
.
deviceTokenModel
.
deviceToken
=
deviceTokenStr
#if DEBUG
YHHUD
.
flash
(
message
:
deviceTokenStr
)
#elseif TESTENV
YHHUD
.
flash
(
message
:
deviceTokenStr
)
#else
#endif
}
//获取token 失败
func
application
(
_
application
:
UIApplication
,
didFailToRegisterForRemoteNotificationsWithError
error
:
Error
)
{
//可选
print
(
"did Fail To Register For Remote Notifications With Error:
\(
error
)
"
)
#if DEBUG
YHHUD
.
flash
(
message
:
error
.
localizedDescription
)
#elseif TESTENV
YHHUD
.
flash
(
message
:
error
.
localizedDescription
)
#else
#endif
}
//点推送进来执行这个方法
func
application
(
_
application
:
UIApplication
,
didReceiveRemoteNotification
userInfo
:
[
AnyHashable
:
Any
],
fetchCompletionHandler
completionHandler
:
@escaping
(
UIBackgroundFetchResult
)
->
Void
)
{
JPUSHService
.
handleRemoteNotification
(
userInfo
)
completionHandler
(
UIBackgroundFetchResult
.
newData
)
JPUSHService
.
handleRemoteNotification
(
userInfo
)
completionHandler
(
UIBackgroundFetchResult
.
newData
)
// 转换到消息tab
YHLoginManager
.
shared
.
needJumpToMsgTabFlag
=
true
DispatchQueue
.
main
.
asyncAfter
(
deadline
:
.
now
()
+
0.25
,
execute
:
{
goTabBarBy
(
tabType
:
.
message
)
})
}
//后台进前台
...
...
@@ -75,9 +97,9 @@ extension AppDelegate: JPUSHRegisterDelegate {
if
notification
.
request
.
trigger
is
UNPushNotificationTrigger
{
JPUSHService
.
handleRemoteNotification
(
userInfo
)
}
// 需要执行这个方法,选择是否提醒用户,有Badge、Sound、Alert三种类型可以选择设置
completionHandler
(
Int
(
UNNotificationPresentationOptions
.
alert
.
rawValue
))
// 显示通知时需要刷新消息列表和消息未读总数
// 需要执行这个方法,选择是否提醒用户,有Badge、Sound、Alert三种类型可以选择设置
completionHandler
(
Int
(
UNNotificationPresentationOptions
.
alert
.
rawValue
))
// 显示通知时需要刷新消息列表和消息未读总数
DispatchQueue
.
main
.
async
{
// 请求消息未读总数通知
NotificationCenter
.
default
.
post
(
name
:
YhConstant
.
YhNotification
.
didRequestUnreadMsgTotalCountNotification
,
object
:
nil
)
...
...
@@ -85,9 +107,9 @@ extension AppDelegate: JPUSHRegisterDelegate {
NotificationCenter
.
default
.
post
(
name
:
YhConstant
.
YhNotification
.
didRequestUnreadMsgListNotification
,
object
:
nil
)
}
}
func
jpushNotificationCenter
(
_
center
:
UNUserNotificationCenter
,
didReceive
response
:
UNNotificationResponse
,
withCompletionHandler
completionHandler
:
(()
->
Void
))
{
let
userInfo
=
response
.
notification
.
request
.
content
.
userInfo
let
userInfo
=
response
.
notification
.
request
.
content
.
userInfo
if
response
.
notification
.
request
.
trigger
is
UNPushNotificationTrigger
{
JPUSHService
.
handleRemoteNotification
(
userInfo
)
}
...
...
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