Bark/NotificationServiceExtension/Processor/AutoCopyProcessor.swift
2025-08-26 14:31:44 +08:00

26 lines
817 B
Swift

//
// AutoCopyProcessor.swift
// NotificationServiceExtension
//
// Created by huangfeng on 2024/5/29.
// Copyright © 2024 Fin. All rights reserved.
//
import Foundation
class AutoCopyProcessor: NotificationContentProcessor {
func process(identifier: String, content bestAttemptContent: UNMutableNotificationContent) async throws -> UNMutableNotificationContent {
let userInfo = bestAttemptContent.userInfo
if userInfo["autocopy"] as? String == "1"
|| userInfo["automaticallycopy"] as? String == "1"
{
if let copy = userInfo["copy"] as? String {
UIPasteboard.general.string = copy
} else {
UIPasteboard.general.string = bestAttemptContent.bodyText
}
}
return bestAttemptContent
}
}