新增通知中断级别参数

This commit is contained in:
Fin 2021-10-25 12:40:51 +08:00
parent 3adf99e93e
commit 0cea545dbd

View File

@ -250,6 +250,19 @@ class NotificationService: UNNotificationServiceExtension {
let userInfo = bestAttemptContent.userInfo
//
if #available(iOSApplicationExtension 15.0, *) {
if let level = userInfo["level"] as? String {
let interruptionLevels: [String: UNNotificationInterruptionLevel] = [
"passive": UNNotificationInterruptionLevel.passive,
"active": UNNotificationInterruptionLevel.active,
"timeSensitive": UNNotificationInterruptionLevel.timeSensitive,
"critical": UNNotificationInterruptionLevel.critical,
]
bestAttemptContent.interruptionLevel = interruptionLevels[level] ?? .active
}
}
//
autoCopy(userInfo, defaultCopy: bestAttemptContent.body)
//