diff --git a/.DS_Store b/.DS_Store index e41ab3a..d3b5ca3 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/OrderScheduling.xcodeproj/project.pbxproj b/OrderScheduling.xcodeproj/project.pbxproj index e07dc84..37ca689 100644 --- a/OrderScheduling.xcodeproj/project.pbxproj +++ b/OrderScheduling.xcodeproj/project.pbxproj @@ -64,6 +64,14 @@ 79FB76132A9C6CC100DB00A4 /* newOrderAudio.wav in Resources */ = {isa = PBXBuildFile; fileRef = 79FB76122A9C6CC100DB00A4 /* newOrderAudio.wav */; }; 79FB76152A9DEE7400DB00A4 /* RefuseOrderConfirmView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FB76142A9DEE7400DB00A4 /* RefuseOrderConfirmView.swift */; }; 79FB76172A9DFC9600DB00A4 /* NotificationSetUpController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FB76162A9DFC9600DB00A4 /* NotificationSetUpController.swift */; }; + 79FB761C2A9EEC3700DB00A4 /* GroupData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FB761B2A9EEC3700DB00A4 /* GroupData.swift */; }; + 79FB761D2A9EED4A00DB00A4 /* GroupData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FB761B2A9EEC3700DB00A4 /* GroupData.swift */; }; + 79FB761E2A9EED5600DB00A4 /* UserDefaultStrings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7918877F2A7CE6F1007EA0C1 /* UserDefaultStrings.swift */; }; + 79FB761F2A9EEDAD00DB00A4 /* AppKeyStrings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 791887812A7CE71D007EA0C1 /* AppKeyStrings.swift */; }; + 79FB76202A9EEE3700DB00A4 /* EnvironmentStrings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 791887B92A82495D007EA0C1 /* EnvironmentStrings.swift */; }; + 79FB76222A9EEED900DB00A4 /* CommonKeyStrings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FB76212A9EEED900DB00A4 /* CommonKeyStrings.swift */; }; + 79FB76232A9EEF8800DB00A4 /* CommonKeyStrings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FB76212A9EEED900DB00A4 /* CommonKeyStrings.swift */; }; + 79FB76262A9F0A0000DB00A4 /* BackgroundTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FB76252A9F0A0000DB00A4 /* BackgroundTask.swift */; }; A64E95F00B82DC28C2B9306E /* libPods-OrderScheduling.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 98784A61C325B3D6C408016C /* libPods-OrderScheduling.a */; }; /* End PBXBuildFile section */ @@ -173,6 +181,9 @@ 79FB76122A9C6CC100DB00A4 /* newOrderAudio.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = newOrderAudio.wav; sourceTree = ""; }; 79FB76142A9DEE7400DB00A4 /* RefuseOrderConfirmView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RefuseOrderConfirmView.swift; sourceTree = ""; }; 79FB76162A9DFC9600DB00A4 /* NotificationSetUpController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationSetUpController.swift; sourceTree = ""; }; + 79FB761B2A9EEC3700DB00A4 /* GroupData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GroupData.swift; sourceTree = ""; }; + 79FB76212A9EEED900DB00A4 /* CommonKeyStrings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonKeyStrings.swift; sourceTree = ""; }; + 79FB76252A9F0A0000DB00A4 /* BackgroundTask.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackgroundTask.swift; sourceTree = ""; }; 9758FDE3BEDA5A983CAE2DED /* Pods-OrderSchedulingNotificationService.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OrderSchedulingNotificationService.debug.xcconfig"; path = "Target Support Files/Pods-OrderSchedulingNotificationService/Pods-OrderSchedulingNotificationService.debug.xcconfig"; sourceTree = ""; }; 98784A61C325B3D6C408016C /* libPods-OrderScheduling.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-OrderScheduling.a"; sourceTree = BUILT_PRODUCTS_DIR; }; BD034FA1DD7C17CCBA6B0E5D /* Pods-OrderScheduling.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OrderScheduling.release.xcconfig"; path = "Target Support Files/Pods-OrderScheduling/Pods-OrderScheduling.release.xcconfig"; sourceTree = ""; }; @@ -269,6 +280,7 @@ 791887962A80C6CD007EA0C1 /* LocalizedStrings.swift */, 791887B92A82495D007EA0C1 /* EnvironmentStrings.swift */, 791887BE2A839716007EA0C1 /* EntryStrings.swift */, + 79FB76212A9EEED900DB00A4 /* CommonKeyStrings.swift */, ); path = Strings; sourceTree = ""; @@ -353,6 +365,8 @@ 791887AB2A80F930007EA0C1 /* Global */ = { isa = PBXGroup; children = ( + 79FB76242A9F09F400DB00A4 /* BackgroundTask */, + 79FB761A2A9EEC3700DB00A4 /* GroupData */, 79DD0DB22A95F00000768FE7 /* Extension */, 791887C22A84BFCD007EA0C1 /* Tool */, 791887AC2A80F930007EA0C1 /* User */, @@ -687,6 +701,22 @@ path = OrderSchedulingNotificationService; sourceTree = ""; }; + 79FB761A2A9EEC3700DB00A4 /* GroupData */ = { + isa = PBXGroup; + children = ( + 79FB761B2A9EEC3700DB00A4 /* GroupData.swift */, + ); + path = GroupData; + sourceTree = ""; + }; + 79FB76242A9F09F400DB00A4 /* BackgroundTask */ = { + isa = PBXGroup; + children = ( + 79FB76252A9F0A0000DB00A4 /* BackgroundTask.swift */, + ); + path = BackgroundTask; + sourceTree = ""; + }; 8AE7BC9A61FB797B2DAF5A9C /* Pods */ = { isa = PBXGroup; children = ( @@ -905,6 +935,7 @@ 7918878F2A809E37007EA0C1 /* TimerStrings.swift in Sources */, 7918878B2A7CE9E0007EA0C1 /* main.swift in Sources */, 791887A02A80CA10007EA0C1 /* RequestList.swift in Sources */, + 79FB761C2A9EEC3700DB00A4 /* GroupData.swift in Sources */, 79FB76172A9DFC9600DB00A4 /* NotificationSetUpController.swift in Sources */, 79CECC262A8C749B00B95D8B /* VehicleMonitorVideoController.swift in Sources */, 79DD0DA82A9480D000768FE7 /* NotificationAuthView.swift in Sources */, @@ -913,6 +944,7 @@ 791887802A7CE6F1007EA0C1 /* UserDefaultStrings.swift in Sources */, 79FB75EC2A988EC000DB00A4 /* MessageCenterTool.swift in Sources */, 79FB76152A9DEE7400DB00A4 /* RefuseOrderConfirmView.swift in Sources */, + 79FB76262A9F0A0000DB00A4 /* BackgroundTask.swift in Sources */, 79DD0DB12A94B3DB00768FE7 /* EmptyView.swift in Sources */, 79DD0DAA2A9481BC00768FE7 /* NotificationAuthTool.swift in Sources */, 794FBB1C2A8F4DE900D57BB8 /* MessageView.swift in Sources */, @@ -921,6 +953,7 @@ 791887C12A839784007EA0C1 /* RefuseOrderEntryView.swift in Sources */, 7918877E2A7CE5AD007EA0C1 /* NotificationStrings.swift in Sources */, 79CECC1B2A89F83800B95D8B /* AdditionalPhotoController.swift in Sources */, + 79FB76222A9EEED900DB00A4 /* CommonKeyStrings.swift in Sources */, 79DD0DBB2A971EB300768FE7 /* ZDViewController.swift in Sources */, 791887BF2A839716007EA0C1 /* EntryStrings.swift in Sources */, 794FBB192A8F4AF000D57BB8 /* MessageCount.swift in Sources */, @@ -950,6 +983,11 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 79FB76232A9EEF8800DB00A4 /* CommonKeyStrings.swift in Sources */, + 79FB76202A9EEE3700DB00A4 /* EnvironmentStrings.swift in Sources */, + 79FB761F2A9EEDAD00DB00A4 /* AppKeyStrings.swift in Sources */, + 79FB761E2A9EED5600DB00A4 /* UserDefaultStrings.swift in Sources */, + 79FB761D2A9EED4A00DB00A4 /* GroupData.swift in Sources */, 79FB75F82A9C3BEE00DB00A4 /* NotificationService.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/OrderScheduling.xcworkspace/xcuserdata/zd.xcuserdatad/UserInterfaceState.xcuserstate b/OrderScheduling.xcworkspace/xcuserdata/zd.xcuserdatad/UserInterfaceState.xcuserstate index 4ada88d..162fab0 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 2435b8a..066354a 100644 --- a/OrderScheduling.xcworkspace/xcuserdata/zd.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/OrderScheduling.xcworkspace/xcuserdata/zd.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -253,8 +253,8 @@ filePath = "OrderScheduling/Main/Initial.swift" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "92" - endingLineNumber = "92" + startingLineNumber = "93" + endingLineNumber = "93" landmarkName = "networkErrorHandler(response:)" landmarkType = "7"> @@ -269,8 +269,8 @@ filePath = "OrderScheduling/Main/Initial.swift" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "93" - endingLineNumber = "93" + startingLineNumber = "94" + endingLineNumber = "94" landmarkName = "networkErrorHandler(response:)" landmarkType = "7"> @@ -698,8 +698,8 @@ filePath = "OrderScheduling/Main/Initial.swift" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "109" - endingLineNumber = "109" + startingLineNumber = "110" + endingLineNumber = "110" landmarkName = "errorCodeHandler(response:)" landmarkType = "7"> @@ -714,8 +714,8 @@ filePath = "OrderScheduling/Main/Initial.swift" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "112" - endingLineNumber = "112" + startingLineNumber = "113" + endingLineNumber = "113" landmarkName = "errorCodeHandler(response:)" landmarkType = "7"> @@ -730,8 +730,8 @@ filePath = "OrderScheduling/Main/Initial.swift" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "120" - endingLineNumber = "120" + startingLineNumber = "121" + endingLineNumber = "121" landmarkName = "errorCodeHandler(response:)" landmarkType = "7"> @@ -1431,8 +1431,8 @@ filePath = "OrderScheduling/Main/AppDelegate.swift" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "127" - endingLineNumber = "127" + startingLineNumber = "128" + endingLineNumber = "128" landmarkName = "jpushNotificationAuthorization(_:withInfo:)" landmarkType = "7"> @@ -1447,8 +1447,8 @@ filePath = "OrderScheduling/Main/AppDelegate.swift" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "118" - endingLineNumber = "118" + startingLineNumber = "119" + endingLineNumber = "119" landmarkName = "jpushNotificationCenter(_:didReceive:withCompletionHandler:)" landmarkType = "7"> @@ -1607,8 +1607,8 @@ filePath = "OrderScheduling/Main/Initial.swift" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "78" - endingLineNumber = "78" + startingLineNumber = "79" + endingLineNumber = "79" landmarkName = "changeRootViewController(window:)" landmarkType = "7"> @@ -2098,8 +2098,8 @@ filePath = "OrderScheduling/Main/AppDelegate.swift" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "120" - endingLineNumber = "120" + startingLineNumber = "121" + endingLineNumber = "121" landmarkName = "jpushNotificationCenter(_:didReceive:withCompletionHandler:)" landmarkType = "7"> @@ -2319,8 +2319,8 @@ filePath = "OrderSchedulingNotificationService/NotificationService.swift" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "29" - endingLineNumber = "29" + startingLineNumber = "33" + endingLineNumber = "33" landmarkName = "didReceive(_:withContentHandler:)" landmarkType = "7"> @@ -2335,8 +2335,8 @@ filePath = "OrderSchedulingNotificationService/NotificationService.swift" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "31" - endingLineNumber = "31" + startingLineNumber = "35" + endingLineNumber = "35" landmarkName = "didReceive(_:withContentHandler:)" landmarkType = "7"> @@ -2447,8 +2447,8 @@ filePath = "OrderScheduling/Main/Initial.swift" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "83" - endingLineNumber = "83" + startingLineNumber = "84" + endingLineNumber = "84" landmarkName = "changeRootViewController(window:)" landmarkType = "7"> @@ -2835,22 +2835,6 @@ - - - - @@ -2990,22 +2974,6 @@ - - - - - - - - - - - - - - - - - - + + + + + startingLineNumber = "41" + endingLineNumber = "41" + offsetFromSymbolStart = "200"> + startingLineNumber = "41" + endingLineNumber = "41" + offsetFromSymbolStart = "148"> @@ -3183,94 +3088,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - diff --git a/OrderScheduling/.DS_Store b/OrderScheduling/.DS_Store index d4c3a2e..5e60e5d 100644 Binary files a/OrderScheduling/.DS_Store and b/OrderScheduling/.DS_Store differ diff --git a/OrderScheduling/Assets.xcassets/.DS_Store b/OrderScheduling/Assets.xcassets/.DS_Store new file mode 100644 index 0000000..958adde Binary files /dev/null and b/OrderScheduling/Assets.xcassets/.DS_Store differ diff --git a/OrderScheduling/Common/.DS_Store b/OrderScheduling/Common/.DS_Store index c37cfd0..344ca47 100644 Binary files a/OrderScheduling/Common/.DS_Store and b/OrderScheduling/Common/.DS_Store differ diff --git a/OrderScheduling/Entry/Entry.swift b/OrderScheduling/Entry/Entry.swift index 9310464..7821608 100644 --- a/OrderScheduling/Entry/Entry.swift +++ b/OrderScheduling/Entry/Entry.swift @@ -62,7 +62,7 @@ open class Entry { var attributes = EKAttributes() attributes = .centerFloat attributes.name = name - attributes.precedence = .override(priority: .normal, dropEnqueuedEntries: false) + attributes.precedence = .override(priority: .high, dropEnqueuedEntries: false) attributes.displayMode = .inferred attributes.displayDuration = .infinity attributes.screenBackground = .color(color: .clear) @@ -155,7 +155,7 @@ open class Entry { attributes.displayDuration = .infinity attributes.screenBackground = .color(color: .clear) attributes.entryBackground = .color(color: .white) - attributes.screenInteraction = .dismiss + attributes.screenInteraction = .absorbTouches attributes.entryInteraction = .absorbTouches attributes.scroll = .disabled attributes.entranceAnimation = .init( diff --git a/OrderScheduling/Global/.DS_Store b/OrderScheduling/Global/.DS_Store index 5f31b37..bed0761 100644 Binary files a/OrderScheduling/Global/.DS_Store and b/OrderScheduling/Global/.DS_Store differ diff --git a/OrderScheduling/Global/BackgroundTask/BackgroundTask.swift b/OrderScheduling/Global/BackgroundTask/BackgroundTask.swift new file mode 100644 index 0000000..1241c01 --- /dev/null +++ b/OrderScheduling/Global/BackgroundTask/BackgroundTask.swift @@ -0,0 +1,28 @@ +// +// BackgroundTask.swift +// OrderScheduling +// +// Created by 中道 on 2023/8/30. +// + +import Foundation +import UIKit + +public let BGTASK = BackgroundTask.default + +open class BackgroundTask { + public static let `default` = BackgroundTask() + + public var bgTask : UIBackgroundTaskIdentifier? + + func beginTask() { + bgTask = UIApplication.shared.beginBackgroundTask() + } + + func endTask() { + if let bgTask { + UIApplication.shared.endBackgroundTask(bgTask) + } + bgTask = UIBackgroundTaskIdentifier.invalid + } +} diff --git a/OrderScheduling/Global/GroupData/GroupData.swift b/OrderScheduling/Global/GroupData/GroupData.swift new file mode 100644 index 0000000..261f3f7 --- /dev/null +++ b/OrderScheduling/Global/GroupData/GroupData.swift @@ -0,0 +1,48 @@ +// +// GroupData.swift +// OrderScheduling +// +// Created by 中道 on 2023/8/30. +// + +import Foundation + +public let GROUP = GroupData.default + +open class GroupData { + public static let `default` = GroupData() + let groudUserDefault = UserDefaults(suiteName: GROUPID) + + // 不需要记录 + public var bestAttemptContentUserInfo : [AnyHashable:Any]? { + return groudUserDefault?.object(forKey: bestAttemptContentUserInfo_key) as? [AnyHashable:Any] + } + + func setBestAttemptContentUserInfo(bestAttemptContentUserInfo:[AnyHashable:Any]?) { + groudUserDefault?.set(bestAttemptContentUserInfo, forKey: bestAttemptContentUserInfo_key) + } + + // 不需要记录 + public var newMessageSound : Bool { + return (groudUserDefault?.object(forKey: newMessageSound_key) as? Bool) ?? true + } + + func setNewMessageSound(newMessageSound:Bool?) { + groudUserDefault?.set(newMessageSound, forKey: newMessageSound_key) + } + + // 不需要记录 + public var newMessageAlert : Bool { + return (groudUserDefault?.object(forKey: newMessageAlert_key) as? Bool) ?? true + } + + func setNewMessageAlert(newMessageAlert:Bool?) { + groudUserDefault?.set(newMessageAlert, forKey: newMessageAlert_key) + } + + func clear() { + GROUP.setNewMessageAlert(newMessageAlert: nil) + GROUP.setNewMessageSound(newMessageSound: nil) + GROUP.setBestAttemptContentUserInfo(bestAttemptContentUserInfo: nil) + } +} diff --git a/OrderScheduling/Global/Tool/Tool.swift b/OrderScheduling/Global/Tool/Tool.swift index b93a793..2508716 100644 --- a/OrderScheduling/Global/Tool/Tool.swift +++ b/OrderScheduling/Global/Tool/Tool.swift @@ -137,54 +137,6 @@ open class Tool { } return "未知" } - - func dealAppExtension(completionHandler:(([AnyHashable:Any]) -> Void)?) { - let userDefault = UserDefaults.init(suiteName: GROUPID) - let userInfo = userDefault?.object(forKey: bestAttemptContentUserInfo_key) as? [AnyHashable:Any] - if let userInfo { - if completionHandler != nil { - completionHandler!(userInfo) - } - userDefault?.setValue(nil, forKey: bestAttemptContentUserInfo_key) - } - } - - func playAlertWith(userInfo:[AnyHashable:Any]?) { - if USER.newMessageAlert != true { - return - } - - ACCEPTORDERTOOL.open(userInfo: userInfo) - } - - func playVoiceWith(userInfo:[AnyHashable:Any]?) { - if USER.newMessageSound != true { - return - } - - if let userInfo { - let aps = userInfo["aps"] as? [String:Any] - - if let aps, (aps["alert"] as? String) == "新订单" { - let juheVehcileName = userInfo["juheVehcileName"] as? String - - var auidoUrl : URL? - - if juheVehcileName?.isEmpty == false { - auidoUrl = URL(string: Bundle.main.path(forResource: "newJuheOrderAudio.wav", ofType: nil) ?? "") - }else{ - auidoUrl = URL(string: Bundle.main.path(forResource: "newOrderAudio.wav", ofType: nil) ?? "") - } - - if let auidoUrl { - var audioSoundID:SystemSoundID = 0 - AudioServicesCreateSystemSoundID(auidoUrl as CFURL, &audioSoundID) - AudioServicesPlaySystemSoundWithCompletion(audioSoundID) { - } - } - } - } - } func getOrderString(userInfo:[AnyHashable:Any]?) -> String{ var string : String = "" @@ -204,4 +156,74 @@ open class Tool { return string } + + func dealAppExtension(completionHandler:(([AnyHashable:Any]) -> Void)?) { + let userInfo = GROUP.bestAttemptContentUserInfo + if let userInfo { + if completionHandler != nil { + completionHandler!(userInfo) + } + GROUP.setBestAttemptContentUserInfo(bestAttemptContentUserInfo: nil) + } + } + + func playAlertWith(userInfo:[AnyHashable:Any]?) { + if GROUP.newMessageAlert != true { + return + } + + ACCEPTORDERTOOL.open(userInfo: userInfo) + } + + public var systemSoundID : SystemSoundID? + public var soundCount : Int = 0 + public var needPlayAudio : Bool = true + func playVoiceWith(userInfo:[AnyHashable:Any]?) { + if GROUP.newMessageSound != true { + return + } + + if let userInfo { + let aps = userInfo[aps_key] as? [String:Any] + if let aps, (aps[alert_key] as? String) == "新订单" { + let juheVehcileName = userInfo[juheVehcileName_key] as? String + var auidoUrl : URL? + if juheVehcileName?.isEmpty == false { + auidoUrl = URL(string: Bundle.main.path(forResource: juheNewOrderAudio_key, ofType: nil) ?? "") + }else{ + auidoUrl = URL(string: Bundle.main.path(forResource: newOrderAudio_key, ofType: nil) ?? "") + } + + if let auidoUrl { + var audioSoundID:SystemSoundID = 0 + AudioServicesCreateSystemSoundID(auidoUrl as CFURL, &audioSoundID) + systemSoundID = audioSoundID + needPlayAudio = true + soundCount = 0 + cycleVoice() + } + } + } + } + + func cycleVoice() { + if let systemSoundID, soundCount < 10, needPlayAudio == true { + AudioServicesPlaySystemSoundWithCompletion(systemSoundID) {[weak self] in + self?.soundCount+=1 + DispatchQueue.global().asyncAfter(deadline: .now() + 2, execute: {[weak self] in + self?.cycleVoice() + }) + } + }else{ + systemSoundID = nil + } + } + + func stopVoice() { + if let systemSoundID { + needPlayAudio = false + soundCount = 0 + AudioServicesDisposeSystemSoundID(systemSoundID) + } + } } diff --git a/OrderScheduling/Global/User/UserData.swift b/OrderScheduling/Global/User/UserData.swift index 0704818..ab7d2d0 100644 --- a/OrderScheduling/Global/User/UserData.swift +++ b/OrderScheduling/Global/User/UserData.swift @@ -82,24 +82,6 @@ open class UserData { UserDefaults.standard.set(userId, forKey: userId_key) } - // 不需要记录 - public var newMessageSound : Bool { - return (UserDefaults.standard.object(forKey: newMessageSound_key) as? Bool) ?? true - } - - func setNewMessageSound(newMessageSound:Bool?) { - UserDefaults.standard.set(newMessageSound, forKey: newMessageSound_key) - } - - // 不需要记录 - public var newMessageAlert : Bool { - return (UserDefaults.standard.object(forKey: newMessageAlert_key) as? Bool) ?? true - } - - func setNewMessageAlert(newMessageAlert:Bool?) { - UserDefaults.standard.set(newMessageAlert, forKey: newMessageAlert_key) - } - public var deviceToken : String? public var regId : String? @@ -110,7 +92,5 @@ open class UserData { setSupplierType(supplierType: nil) setUserId(userId: nil) setSupplierId(supplierId: nil) - setNewMessageSound(newMessageSound: nil) - setNewMessageAlert(newMessageAlert: nil) } } diff --git a/OrderScheduling/History/.DS_Store b/OrderScheduling/History/.DS_Store index 6cddc85..bda797a 100644 Binary files a/OrderScheduling/History/.DS_Store and b/OrderScheduling/History/.DS_Store differ diff --git a/OrderScheduling/Login/.DS_Store b/OrderScheduling/Login/.DS_Store index 9d4279d..c819b87 100644 Binary files a/OrderScheduling/Login/.DS_Store and b/OrderScheduling/Login/.DS_Store differ diff --git a/OrderScheduling/Main/AppDelegate.swift b/OrderScheduling/Main/AppDelegate.swift index 8525245..b1df285 100644 --- a/OrderScheduling/Main/AppDelegate.swift +++ b/OrderScheduling/Main/AppDelegate.swift @@ -103,6 +103,7 @@ extension AppDelegate : JPUSHRegisterDelegate { let userInfo = notification.request.content.userInfo if notification.request.trigger?.isKind(of: UNPushNotificationTrigger.self) == true { JPUSHService.handleRemoteNotification(userInfo) + // 只有订单类型才会弹窗和声音 TOOL.dealAppExtension { userInfo in TOOL.playAlertWith(userInfo: userInfo) TOOL.playVoiceWith(userInfo: userInfo) diff --git a/OrderScheduling/Main/Initial.swift b/OrderScheduling/Main/Initial.swift index d145b0b..f15a747 100644 --- a/OrderScheduling/Main/Initial.swift +++ b/OrderScheduling/Main/Initial.swift @@ -75,6 +75,7 @@ class Initial : NSObject { NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: Notification_logoutSuccessToLoginController), object: nil, queue: .main) { note in USER.clear() + GROUP.clear() let nav = DDNavigationController(rootViewController: LoginController.init()) window?.rootViewController = nav } diff --git a/OrderScheduling/Main/SceneDelegate.swift b/OrderScheduling/Main/SceneDelegate.swift index a4c50b6..5eee8fb 100644 --- a/OrderScheduling/Main/SceneDelegate.swift +++ b/OrderScheduling/Main/SceneDelegate.swift @@ -37,7 +37,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { // 后台收到通知后或者不点击通知打开app,激活时消除badge JPUSHService.resetBadge() UIApplication.shared.applicationIconBadgeNumber = 0 - + // 只有订单类型才会弹窗和声音 TOOL.dealAppExtension { userInfo in TOOL.playAlertWith(userInfo: userInfo) } diff --git a/OrderScheduling/MessageCenter/.DS_Store b/OrderScheduling/MessageCenter/.DS_Store index cb71ae1..c3b00d7 100644 Binary files a/OrderScheduling/MessageCenter/.DS_Store and b/OrderScheduling/MessageCenter/.DS_Store differ diff --git a/OrderScheduling/Mine/.DS_Store b/OrderScheduling/Mine/.DS_Store index 6cddc85..c46dcb4 100644 Binary files a/OrderScheduling/Mine/.DS_Store and b/OrderScheduling/Mine/.DS_Store differ diff --git a/OrderScheduling/Mine/ViewController/NotificationSetUpController.swift b/OrderScheduling/Mine/ViewController/NotificationSetUpController.swift index c738d8a..aa020fd 100644 --- a/OrderScheduling/Mine/ViewController/NotificationSetUpController.swift +++ b/OrderScheduling/Mine/ViewController/NotificationSetUpController.swift @@ -36,10 +36,13 @@ extension NotificationSetUpController { // MARK: UITableViewDelegate,UITableViewDataSource extension NotificationSetUpController : UITableViewDelegate,UITableViewDataSource { public func numberOfSections(in tableView: UITableView) -> Int { - return 1 + return 2 } public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + if section == 0 { + return 1 + } return resultArr.count } @@ -48,22 +51,66 @@ extension NotificationSetUpController : UITableViewDelegate,UITableViewDataSourc if cell == nil { cell = NotificationSetUpCell(style: .default, reuseIdentifier: "cell") } - let model = resultArr[indexPath.item] - cell?.nameLabel.text = model.name - cell?.switchButton.isOn = model.isOn - cell?.switchButton.rx.isOn - .subscribe(onNext: { isOn in - if model.type == .sound { - USER.setNewMessageSound(newMessageSound: isOn) - }else if model.type == .alert { - USER.setNewMessageAlert(newMessageAlert: isOn) - } - }) - .disposed(by: disposeBag) + if indexPath.section == 0 { + cell?.arrow.isHidden = false + cell?.switchButton.isHidden = true + cell?.nameLabel.text = "前往设置" + } + + if indexPath.section == 1 { + let model = resultArr[indexPath.item] + cell?.arrow.isHidden = true + cell?.switchButton.isHidden = false + cell?.nameLabel.text = model.name + cell?.switchButton.isOn = model.isOn + cell?.switchButton.rx.isOn + .subscribe(onNext: { isOn in + if model.type == .sound { + GROUP.setNewMessageSound(newMessageSound: isOn) + }else if model.type == .alert { + GROUP.setNewMessageAlert(newMessageAlert: isOn) + } + }) + .disposed(by: disposeBag) + } return cell! } + public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { + let view = DDView() + let label = DDLabel.dd_init(withText: "", font: .mediumFont(auto(13)), textColor: .hex("000000").alpha(0.3)) + view.addSubview(label) + label.snp.makeConstraints { make in + make.left.equalTo(auto(20)) + make.bottom.equalToSuperview() + } + let line = DDView() + line.isHidden = true + line.backgroundColor = .hex("F1F2F5") + view.addSubview(line) + line.snp.makeConstraints { make in + make.left.right.equalToSuperview() + make.bottom.equalToSuperview() + make.height.equalTo(1) + } + if section == 0 { + label.text = "未打开应用时" + }else{ + label.text = "打开应用时" + } + return view + } + + public func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { + return auto(30) + } + public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + if indexPath.section == 0 { + NOTIAUTHTOOL.openSetting() + } + } + public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return auto(44) } @@ -81,10 +128,10 @@ open class NotificationSetUpController : ZDViewController { dd_navigationBarTitleTextAttributes = [.foregroundColor : UIColor.white(alpha: 0.7),.font:UIFont.mediumFont(17)] dd_navigationBarBarButtonItemAttributes = [.foregroundColor : UIColor.white] - let soundModel = NotificationSetUpModel(name: "新消息声音", type: .sound, isOn: USER.newMessageSound) - let alertModel = NotificationSetUpModel(name: "新消息弹窗", type: .alert, isOn: USER.newMessageAlert) + let soundModel = NotificationSetUpModel(name: "新订单提示音", type: .sound, isOn: GROUP.newMessageSound) +// let alertModel = NotificationSetUpModel(name: "新订单弹窗", type: .alert, isOn: GROUP.newMessageAlert) resultArr.append(soundModel) - resultArr.append(alertModel) +// resultArr.append(alertModel) addSubviews() addActions() @@ -130,11 +177,13 @@ class NotificationSetUpCell : DDTableViewCell { public let radiusView : DDView public let nameLabel : DDLabel public let switchButton : UISwitch + public let arrow : DDImageView public let line : DDView override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { radiusView = DDView() nameLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(14)), textColor: .hex("000000").alpha(0.8)) switchButton = UISwitch() + arrow = DDImageView() line = DDView.init() super.init(style: style, reuseIdentifier: reuseIdentifier) @@ -143,6 +192,8 @@ class NotificationSetUpCell : DDTableViewCell { contentView.addSubview(radiusView) radiusView.addSubview(nameLabel) radiusView.addSubview(switchButton) + arrow.image = UIImage(named: "mine_info_arrow") + radiusView.addSubview(arrow) line.backgroundColor = .hex("F1F2F5") radiusView.addSubview(line) @@ -160,6 +211,11 @@ class NotificationSetUpCell : DDTableViewCell { make.centerY.equalToSuperview() } + arrow.snp.makeConstraints { make in + make.right.equalTo(-auto(20)) + make.centerY.equalToSuperview() + } + line.snp.makeConstraints { make in make.bottom.equalToSuperview() make.left.equalTo(auto(20)) diff --git a/OrderScheduling/Rescue/.DS_Store b/OrderScheduling/Rescue/.DS_Store index 6cddc85..8ff09b9 100644 Binary files a/OrderScheduling/Rescue/.DS_Store and b/OrderScheduling/Rescue/.DS_Store differ diff --git a/OrderScheduling/Rescue/View/AcceptOrderTool.swift b/OrderScheduling/Rescue/View/AcceptOrderTool.swift index 0382e19..347322f 100644 --- a/OrderScheduling/Rescue/View/AcceptOrderTool.swift +++ b/OrderScheduling/Rescue/View/AcceptOrderTool.swift @@ -16,7 +16,7 @@ open class AcceptOrderTool : NSObject { private let disposeBag = DisposeBag() func open(userInfo:[AnyHashable:Any]?) { - if USER.newMessageAlert != true { + if GROUP.newMessageAlert != true { return } let acceptOrderView = AcceptOrderView() @@ -26,6 +26,9 @@ open class AcceptOrderTool : NSObject { acceptOrderView.readButton.rx.tap .subscribe(onNext: { ENTRY.dismiss(name: acceptOrderViewEntry) { + // 停止声音播放 + TOOL.stopVoice() + // 来到首页的救援中-待接单 let tabBarVc = UIApplication.shared.dd_keyWindow.rootViewController as? MainTabBarController let currentNav = tabBarVc?.selectedViewController as? UINavigationController currentNav?.popToRootViewController(animated: false) diff --git a/OrderScheduling/ReviewFailed/.DS_Store b/OrderScheduling/ReviewFailed/.DS_Store index 6cddc85..5e65161 100644 Binary files a/OrderScheduling/ReviewFailed/.DS_Store and b/OrderScheduling/ReviewFailed/.DS_Store differ diff --git a/OrderScheduling/Strings/CommonKeyStrings.swift b/OrderScheduling/Strings/CommonKeyStrings.swift new file mode 100644 index 0000000..b858224 --- /dev/null +++ b/OrderScheduling/Strings/CommonKeyStrings.swift @@ -0,0 +1,18 @@ +// +// CommonKeyStrings.swift +// OrderScheduling +// +// Created by 中道 on 2023/8/30. +// + +import Foundation + +public let aps_key = "aps" + +public let alert_key = "alert" + +public let juheVehcileName_key = "juheVehcileName" + +public let juheNewOrderAudio_key = "juheNewOrderAudio.wav" + +public let newOrderAudio_key = "newOrderAudio.wav" diff --git a/OrderScheduling/VehicleMonitoring/.DS_Store b/OrderScheduling/VehicleMonitoring/.DS_Store index 6cddc85..d48252a 100644 Binary files a/OrderScheduling/VehicleMonitoring/.DS_Store and b/OrderScheduling/VehicleMonitoring/.DS_Store differ diff --git a/OrderSchedulingNotificationService/NotificationService.swift b/OrderSchedulingNotificationService/NotificationService.swift index 7b00ad2..8089804 100644 --- a/OrderSchedulingNotificationService/NotificationService.swift +++ b/OrderSchedulingNotificationService/NotificationService.swift @@ -21,21 +21,25 @@ class NotificationService: UNNotificationServiceExtension { // Modify the notification content here... // bestAttemptContent.title = "\(bestAttemptContent.title) [modified]" let userInfo = bestAttemptContent.userInfo - - let aps = userInfo["aps"] as? [String:Any] - if let aps, (aps["alert"] as? String) == "新订单" { - let juheVehcileName = userInfo["juheVehcileName"] as? String + + // 只有订单类型才写入group,因为需要弹窗和声音 + let aps = userInfo[aps_key] as? [String:Any] + if let aps, (aps[alert_key] as? String) == "新订单" { + var sound : UNNotificationSound? + + let juheVehcileName = userInfo[juheVehcileName_key] as? String if juheVehcileName?.isEmpty == false { - bestAttemptContent.sound = UNNotificationSound(named: UNNotificationSoundName(rawValue: "juheNewOrderAudio.wav")) + sound = UNNotificationSound(named: UNNotificationSoundName(rawValue: juheNewOrderAudio_key)) }else{ - bestAttemptContent.sound = UNNotificationSound(named: UNNotificationSoundName(rawValue: "newOrderAudio.wav")) + sound = UNNotificationSound(named: UNNotificationSoundName(rawValue: newOrderAudio_key)) } + + bestAttemptContent.sound = sound + + GROUP.setBestAttemptContentUserInfo(bestAttemptContentUserInfo: userInfo) } - - let userDefault = UserDefaults.init(suiteName: "group.com.sino.supplier") - userDefault?.setValue(userInfo, forKey: "bestAttemptContentUserInfo_key") - JPushNotificationExtensionService.jpushSetAppkey("259b546bb2aaf5f02ffa2547") + JPushNotificationExtensionService.jpushSetAppkey(JPushKey) JPushNotificationExtensionService.jpushReceive(request) { contentHandler(request.content) } diff --git a/Pods/.DS_Store b/Pods/.DS_Store index cbb5832..0f8b5ba 100644 Binary files a/Pods/.DS_Store and b/Pods/.DS_Store differ diff --git a/Pods/AMapNavi-NO-IDFA/AMapNaviKit.framework/.DS_Store b/Pods/AMapNavi-NO-IDFA/AMapNaviKit.framework/.DS_Store new file mode 100644 index 0000000..4eddb05 Binary files /dev/null and b/Pods/AMapNavi-NO-IDFA/AMapNaviKit.framework/.DS_Store differ diff --git a/Pods/JCore/jcore-ios-4.2.1.xcframework/.DS_Store b/Pods/JCore/jcore-ios-4.2.1.xcframework/.DS_Store new file mode 100644 index 0000000..bf17643 Binary files /dev/null and b/Pods/JCore/jcore-ios-4.2.1.xcframework/.DS_Store differ diff --git a/Pods/JPush/jpush-ios-5.0.1.xcframework/.DS_Store b/Pods/JPush/jpush-ios-5.0.1.xcframework/.DS_Store new file mode 100644 index 0000000..4689ccc Binary files /dev/null and b/Pods/JPush/jpush-ios-5.0.1.xcframework/.DS_Store differ