diff --git a/NotificationServiceExtension/Processor/CallProcessor.swift b/NotificationServiceExtension/Processor/CallProcessor.swift index a92e85ca..69b63f17 100644 --- a/NotificationServiceExtension/Processor/CallProcessor.swift +++ b/NotificationServiceExtension/Processor/CallProcessor.swift @@ -40,7 +40,7 @@ extension CallProcessor { } if let longSoundUrl = getLongSound(soundName: soundName, soundType: soundType) { - if let level = content.userInfo["level"] as? String, level == "critical" { + if content.isCritical { LevelProcessor.setCriticalSound(content: content, soundName: longSoundUrl.lastPathComponent) } else { content.sound = UNNotificationSound(named: UNNotificationSoundName(rawValue: longSoundUrl.lastPathComponent)) diff --git a/NotificationServiceExtension/Processor/LevelProcessor.swift b/NotificationServiceExtension/Processor/LevelProcessor.swift index 63a0b595..913f89a0 100644 --- a/NotificationServiceExtension/Processor/LevelProcessor.swift +++ b/NotificationServiceExtension/Processor/LevelProcessor.swift @@ -15,7 +15,7 @@ class LevelProcessor: NotificationContentProcessor { return bestAttemptContent } - if let level = bestAttemptContent.userInfo["level"] as? String, level == "critical" { + if bestAttemptContent.isCritical { // 设置重要警告音效 LevelProcessor.setCriticalSound(content: bestAttemptContent) return bestAttemptContent @@ -39,7 +39,7 @@ class LevelProcessor: NotificationContentProcessor { extension LevelProcessor { class func setCriticalSound(content bestAttemptContent: UNMutableNotificationContent, soundName: String? = nil) { - guard let level = bestAttemptContent.userInfo["level"] as? String, level == "critical" else { + guard bestAttemptContent.isCritical else { return } // 默认音量