This commit is contained in:
DDIsFriend
2023-09-06 15:17:24 +08:00
parent 177b77c044
commit 7fda9d2650
37 changed files with 9331 additions and 8117 deletions

View File

@@ -19,6 +19,11 @@ class NotificationService: UNNotificationServiceExtension {
if let bestAttemptContent = bestAttemptContent {
// Modify the notification content here...
JPushNotificationExtensionService.jpushSetAppkey(JPushKey)
JPushNotificationExtensionService.jpushReceive(request) {
contentHandler(request.content)
}
let userInfo = bestAttemptContent.userInfo
if let dict = GROUP.parserAlertToDictionary(userInfo: userInfo) {
@@ -46,16 +51,23 @@ class NotificationService: UNNotificationServiceExtension {
bestAttemptContent.sound = sound
GROUP.setBestAttemptContentUserInfo(bestAttemptContentUserInfo: userInfo)
contentHandler(bestAttemptContent)
}else{
bestAttemptContent.sound = .default
if let isShowPop = (userInfo[pushNoti_broadcastKeywords_key] as? Bool), isShowPop == true {
if let userInfo = GROUP.bestAttemptContentUserInfo,GROUP.isOrderPushNotification(userInfo: userInfo) == true {
}else{
GROUP.setBestAttemptContentUserInfo(bestAttemptContentUserInfo: userInfo)
}
}
if let broadcastKeywords = (userInfo[pushNoti_broadcastKeywords_key] as? String),broadcastKeywords.isEmpty == false {
bestAttemptContent.sound = .default
contentHandler(bestAttemptContent)
}else{
bestAttemptContent.sound = .default
contentHandler(bestAttemptContent)
}
}
JPushNotificationExtensionService.jpushSetAppkey(JPushKey)
JPushNotificationExtensionService.jpushReceive(request) {
contentHandler(request.content)
}
contentHandler(bestAttemptContent)
}
}
@@ -63,6 +75,20 @@ class NotificationService: UNNotificationServiceExtension {
// Called just before the extension will be terminated by the system.
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
let userInfo = bestAttemptContent.userInfo
if let dict = GROUP.parserAlertToDictionary(userInfo: userInfo) {
if let title = dict[pushNoti_title_key] {
bestAttemptContent.title = title
}
if let body = dict[pushNoti_body_key] {
bestAttemptContent.body = body
}
}else if let body = GROUP.parserAlertToString(userInfo: userInfo) {
bestAttemptContent.body = body
}
bestAttemptContent.sound = .default
contentHandler(bestAttemptContent)
}
}