Skip to content

Commit

Permalink
优化重要警告判断代码
Browse files Browse the repository at this point in the history
  • Loading branch information
Finb committed Jan 24, 2025
1 parent 3513d2a commit 8b49d6c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion NotificationServiceExtension/Processor/CallProcessor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions NotificationServiceExtension/Processor/LevelProcessor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
// 默认音量
Expand Down

0 comments on commit 8b49d6c

Please sign in to comment.