mirror of
https://github.com/Finb/Bark.git
synced 2025-12-08 21:36:01 +00:00
29 lines
1.1 KiB
Swift
29 lines
1.1 KiB
Swift
//
|
|
// LevelProcessor.swift
|
|
// NotificationServiceExtension
|
|
//
|
|
// Created by huangfeng on 2024/5/29.
|
|
// Copyright © 2024 Fin. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
/// 通知中断级别
|
|
class LevelProcessor: NotificationContentProcessor {
|
|
func process(content bestAttemptContent: UNMutableNotificationContent) async throws -> UNMutableNotificationContent {
|
|
if #available(iOSApplicationExtension 15.0, *) {
|
|
if let level = bestAttemptContent.userInfo["level"] as? String {
|
|
let interruptionLevels: [String: UNNotificationInterruptionLevel] = [
|
|
"passive": UNNotificationInterruptionLevel.passive,
|
|
"active": UNNotificationInterruptionLevel.active,
|
|
"timeSensitive": UNNotificationInterruptionLevel.timeSensitive,
|
|
"timesensitive": UNNotificationInterruptionLevel.timeSensitive,
|
|
"critical": UNNotificationInterruptionLevel.critical
|
|
]
|
|
bestAttemptContent.interruptionLevel = interruptionLevels[level] ?? .active
|
|
}
|
|
}
|
|
return bestAttemptContent
|
|
}
|
|
}
|