mirror of
https://github.com/lux-tel/session-ios.git
synced 2026-10-30 20:38:32 +00:00
# Conflicts: # Session.xcodeproj/project.pbxproj # SessionMessagingKit/Open Groups/OpenGroupManager.swift # SessionMessagingKit/Sending & Receiving/Notifications/NotificationsProtocol.swift # SessionMessagingKit/Sending & Receiving/Notifications/Types/NotificationCategory.swift # SessionMessagingKitTests/_TestUtilities/CommonSMKMockExtensions.swift # SessionMessagingKitTests/_TestUtilities/MockNotificationsManager.swift # SessionNotificationServiceExtension/NSENotificationPresenter.swift # SessionUtilitiesKit/General/SessionId.swift
69 lines
2.4 KiB
Swift
69 lines
2.4 KiB
Swift
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import Foundation
|
|
import Combine
|
|
import UserNotifications
|
|
import SessionMessagingKit
|
|
import SignalUtilitiesKit
|
|
import SessionUtilitiesKit
|
|
|
|
class UserNotificationConfig {
|
|
class var allNotificationCategories: Set<UNNotificationCategory> {
|
|
let categories = NotificationCategory.allCases.map { notificationCategory($0) }
|
|
return Set(categories)
|
|
}
|
|
|
|
class func notificationActions(for category: NotificationCategory) -> [UNNotificationAction] {
|
|
return category.actions.map { notificationAction($0) }
|
|
}
|
|
|
|
class func notificationCategory(_ category: NotificationCategory) -> UNNotificationCategory {
|
|
return UNNotificationCategory(
|
|
identifier: category.identifier,
|
|
actions: notificationActions(for: category),
|
|
intentIdentifiers: [],
|
|
options: []
|
|
)
|
|
}
|
|
|
|
class func notificationAction(_ action: AppNotificationAction) -> UNNotificationAction {
|
|
switch action {
|
|
case .markAsRead:
|
|
return UNNotificationAction(
|
|
identifier: action.identifier,
|
|
title: "messageMarkRead".localized(),
|
|
options: []
|
|
)
|
|
|
|
case .reply:
|
|
return UNTextInputNotificationAction(
|
|
identifier: action.identifier,
|
|
title: "reply".localized(),
|
|
options: [],
|
|
textInputButtonTitle: "send".localized(),
|
|
textInputPlaceholder: ""
|
|
)
|
|
|
|
// TODO: Remove in future release
|
|
case .deprecatedMarkAsRead:
|
|
return UNNotificationAction(
|
|
identifier: action.identifier,
|
|
title: "messageMarkRead".localized(),
|
|
options: []
|
|
)
|
|
case .deprecatedReply:
|
|
return UNTextInputNotificationAction(
|
|
identifier: action.identifier,
|
|
title: "reply".localized(),
|
|
options: [],
|
|
textInputButtonTitle: "send".localized(),
|
|
textInputPlaceholder: ""
|
|
)
|
|
}
|
|
}
|
|
|
|
class func action(identifier: String) -> AppNotificationAction? {
|
|
return AppNotificationAction.allCases.first { notificationAction($0).identifier == identifier }
|
|
}
|
|
}
|