Bark/NotificationServiceExtension/Processor/NotificationContentProcessor.swift
2024-05-29 15:14:12 +08:00

52 lines
1.4 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// NotificationContentProcessor.swift
// NotificationServiceExtension
//
// Created by huangfeng on 2024/5/29.
// Copyright © 2024 Fin. All rights reserved.
//
import Foundation
@_exported import UserNotifications
enum NotificationContentProcessorItem {
case ciphertext
case level
case badge
case autoCopy
case archive
case setIcon
case setImage
var processor: NotificationContentProcessor {
switch self {
case .ciphertext:
return CiphertextProcessor()
case .level:
return LevelProcessor()
case .badge:
return BadgeProcessor()
case .autoCopy:
return AutoCopyProcessor()
case .archive:
return ArchiveProcessor()
case .setIcon:
return IconProcessor()
case .setImage:
return ImageProcessor()
}
}
}
enum NotificationContentProcessorError: Swift.Error {
case error(content: UNMutableNotificationContent)
}
public protocol NotificationContentProcessor {
/// UNMutableNotificationContent
/// - Parameter bestAttemptContent: UNMutableNotificationContent
/// - Returns: UNMutableNotificationContent
/// - Throws:
func process(content bestAttemptContent: UNMutableNotificationContent) async throws -> UNMutableNotificationContent
}