mirror of
https://github.com/Finb/Bark.git
synced 2025-12-08 21:36:01 +00:00
优化重要警告判断代码
This commit is contained in:
parent
3513d2afb3
commit
8b49d6cc96
@ -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))
|
||||
|
||||
@ -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
|
||||
}
|
||||
// 默认音量
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user