diff --git a/.DS_Store b/.DS_Store index d3b5ca3..24d9826 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/OrderScheduling.xcworkspace/xcuserdata/zd.xcuserdatad/UserInterfaceState.xcuserstate b/OrderScheduling.xcworkspace/xcuserdata/zd.xcuserdatad/UserInterfaceState.xcuserstate index 597c8e0..709d3f5 100644 Binary files a/OrderScheduling.xcworkspace/xcuserdata/zd.xcuserdatad/UserInterfaceState.xcuserstate and b/OrderScheduling.xcworkspace/xcuserdata/zd.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/OrderScheduling.xcworkspace/xcuserdata/zd.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/OrderScheduling.xcworkspace/xcuserdata/zd.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 40c2645..250743e 100644 --- a/OrderScheduling.xcworkspace/xcuserdata/zd.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/OrderScheduling.xcworkspace/xcuserdata/zd.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -2636,8 +2636,8 @@ filePath = "OrderSchedulingNotificationService/NotificationService.swift" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "47" - endingLineNumber = "47" + startingLineNumber = "57" + endingLineNumber = "57" landmarkName = "didReceive(_:withContentHandler:)" landmarkType = "7"> @@ -3004,5 +3004,132 @@ landmarkType = "7"> + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OrderScheduling/.DS_Store b/OrderScheduling/.DS_Store index 5e60e5d..e012a07 100644 Binary files a/OrderScheduling/.DS_Store and b/OrderScheduling/.DS_Store differ diff --git a/OrderScheduling/Global/GroupData/GroupData.swift b/OrderScheduling/Global/GroupData/GroupData.swift index 83b12a1..3c9c20f 100644 --- a/OrderScheduling/Global/GroupData/GroupData.swift +++ b/OrderScheduling/Global/GroupData/GroupData.swift @@ -13,10 +13,31 @@ open class GroupData { public static let `default` = GroupData() let groudUserDefault = UserDefaults(suiteName: GROUPID) + // 判断推送能不能解析出字典 + func parserAlertToDictionary(userInfo:[AnyHashable:Any]?) -> Dictionary? { + let aps = userInfo?[pushNoti_aps_key] as? [String:Any] + + if let data = (aps?[pushNoti_alert_key] as? String)?.data(using: .utf8) { + let dict = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: String] + return dict + } + + return nil + } + + func parserAlertToString(userInfo:[AnyHashable:Any]?) -> String? { + let aps = userInfo?[pushNoti_aps_key] as? [String:Any] + let string = aps?[pushNoti_alert_key] as? String + return string + } + // 判断新推送是不是新订单 func isOrderPushNotification(userInfo:[AnyHashable:Any]?) -> Bool { if let userInfo { - if let aps = userInfo[pushNoti_aps_key] as? [String:Any], let dict = (aps[pushNoti_alert_key] as? Dictionary), (dict[pushNoti_title_key] as? String) == pushNoti_newOrder_key { + if let dict = parserAlertToDictionary(userInfo: userInfo), dict[pushNoti_title_key] == pushNoti_newOrder_key { + return true + } + if let string = parserAlertToString(userInfo: userInfo), string.contains(pushNoti_newOrder_key) == true { return true } } diff --git a/OrderSchedulingNotificationService/NotificationService.swift b/OrderSchedulingNotificationService/NotificationService.swift index f0e08aa..89948f5 100644 --- a/OrderSchedulingNotificationService/NotificationService.swift +++ b/OrderSchedulingNotificationService/NotificationService.swift @@ -19,9 +19,19 @@ class NotificationService: UNNotificationServiceExtension { if let bestAttemptContent = bestAttemptContent { // Modify the notification content here... -// bestAttemptContent.title = "\(bestAttemptContent.title) [modified]" 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 + } + // 只有订单类型才写入group,因为需要弹窗和声音 if GROUP.isOrderPushNotification(userInfo: userInfo) == true { var sound : UNNotificationSound? diff --git a/Pods/.DS_Store b/Pods/.DS_Store index 0f8b5ba..c3c1e1e 100644 Binary files a/Pods/.DS_Store and b/Pods/.DS_Store differ diff --git a/Pods/AMapNavi-NO-IDFA/.DS_Store b/Pods/AMapNavi-NO-IDFA/.DS_Store new file mode 100644 index 0000000..81dcd44 Binary files /dev/null and b/Pods/AMapNavi-NO-IDFA/.DS_Store differ diff --git a/Pods/AMapNavi-NO-IDFA/AMapNaviKit.framework/.DS_Store b/Pods/AMapNavi-NO-IDFA/AMapNaviKit.framework/.DS_Store index 4eddb05..a921774 100644 Binary files a/Pods/AMapNavi-NO-IDFA/AMapNaviKit.framework/.DS_Store and b/Pods/AMapNavi-NO-IDFA/AMapNaviKit.framework/.DS_Store differ diff --git a/Pods/JCore/.DS_Store b/Pods/JCore/.DS_Store new file mode 100644 index 0000000..e7be9d1 Binary files /dev/null and b/Pods/JCore/.DS_Store differ diff --git a/Pods/JPush/.DS_Store b/Pods/JPush/.DS_Store new file mode 100644 index 0000000..3e8820a Binary files /dev/null and b/Pods/JPush/.DS_Store differ