mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
27 lines
985 B
Swift
27 lines
985 B
Swift
import UserNotifications
|
|
|
|
class NotificationService: UNNotificationServiceExtension {
|
|
var contentHandler: ((UNNotificationContent) -> Void)?
|
|
var bestAttemptContent: UNMutableNotificationContent?
|
|
|
|
override init() {
|
|
super.init()
|
|
}
|
|
|
|
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
|
|
self.contentHandler = contentHandler
|
|
self.bestAttemptContent = request.content.mutableCopy() as? UNMutableNotificationContent
|
|
|
|
if let bestAttemptContent = self.bestAttemptContent {
|
|
bestAttemptContent.title = "\(bestAttemptContent.title) [modified]"
|
|
contentHandler(bestAttemptContent)
|
|
}
|
|
}
|
|
|
|
override func serviceExtensionTimeWillExpire() {
|
|
if let contentHandler = self.contentHandler, let bestAttemptContent = self.bestAttemptContent {
|
|
contentHandler(bestAttemptContent)
|
|
}
|
|
}
|
|
}
|