From 0cea545dbd79595b2a609d4dd05cd2c9f2f17ade Mon Sep 17 00:00:00 2001 From: Fin Date: Mon, 25 Oct 2021 12:40:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=80=9A=E7=9F=A5=E4=B8=AD?= =?UTF-8?q?=E6=96=AD=E7=BA=A7=E5=88=AB=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NotificationService.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/NotificationServiceExtension/NotificationService.swift b/NotificationServiceExtension/NotificationService.swift index a9f7e0d..9b204b4 100644 --- a/NotificationServiceExtension/NotificationService.swift +++ b/NotificationServiceExtension/NotificationService.swift @@ -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) // 保存推送