Я хочу показать разные заголовки для каждого уведомления. Я могу добиться этого, назначив категорию и действие центру уведомлений в NotificationServices. Но проблема в том, что при наличии двух уведомлений последний текст действия переопределяет предыдущий.
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
guard let bestAttemptContent = bestAttemptContent else {
return
}
if let category = bestAttemptContent.categoryIdentifier as? String {
if let cta = bestAttemptContent.userInfo["cta"] as? String {
if category == "default" {
let customeAction = UNNotificationAction(identifier: "custom", title: cta, options: [])
let category = UNNotificationCategory(identifier: "default", actions: [customeAction], intentIdentifiers: ["custom"], options: [])
UNUserNotificationCenter.current().setNotificationCategories([category])
}
if category == "carousel" {
let customeAction = UNNotificationAction(identifier: "OpenNotification", title: cta, options: [])
let category = UNNotificationCategory(identifier: "carousel", actions: [customeAction], intentIdentifiers: [], options: [])
UNUserNotificationCenter.current().setNotificationCategories([category])
}
}
}
Пожалуйста, помогите.