From 8b49d6cc961aaa2fe7a697bf699bc216181c241e Mon Sep 17 00:00:00 2001 From: Fin Date: Fri, 24 Jan 2025 14:47:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=87=8D=E8=A6=81=E8=AD=A6?= =?UTF-8?q?=E5=91=8A=E5=88=A4=E6=96=AD=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NotificationServiceExtension/Processor/CallProcessor.swift | 2 +- NotificationServiceExtension/Processor/LevelProcessor.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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 } // 默认音量