mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Notifications are now handled when the app is in a killed state (#801)
* WIP, added support for receiver id and managed a way to store the app router state * WIP, added support for receiver id and managed a way to store the app router state * Notification Manager is now becoming the UNUserNotificationDelegate ASAP * code improvements + changelog * fixed Unit Tests * pr suggestions
This commit is contained in:
@@ -20,10 +20,9 @@ import UserNotifications
|
||||
|
||||
class NotificationManager: NSObject, NotificationManagerProtocol {
|
||||
private let notificationCenter: UserNotificationCenterProtocol
|
||||
private let clientProxy: ClientProxyProtocol
|
||||
private var clientProxy: ClientProxyProtocol?
|
||||
|
||||
init(clientProxy: ClientProxyProtocol, notificationCenter: UserNotificationCenterProtocol = UNUserNotificationCenter.current()) {
|
||||
self.clientProxy = clientProxy
|
||||
init(notificationCenter: UserNotificationCenterProtocol = UNUserNotificationCenter.current()) {
|
||||
self.notificationCenter = notificationCenter
|
||||
super.init()
|
||||
}
|
||||
@@ -32,10 +31,6 @@ class NotificationManager: NSObject, NotificationManagerProtocol {
|
||||
|
||||
weak var delegate: NotificationManagerDelegate?
|
||||
|
||||
var isAvailable: Bool {
|
||||
true
|
||||
}
|
||||
|
||||
func start() {
|
||||
let replyAction = UNTextInputNotificationAction(identifier: NotificationConstants.Action.inlineReply,
|
||||
title: L10n.actionQuickReply,
|
||||
@@ -46,6 +41,9 @@ class NotificationManager: NSObject, NotificationManagerProtocol {
|
||||
options: [])
|
||||
notificationCenter.setNotificationCategories([replyCategory])
|
||||
notificationCenter.delegate = self
|
||||
}
|
||||
|
||||
func requestAuthorization() {
|
||||
Task {
|
||||
do {
|
||||
let granted = try await notificationCenter.requestAuthorization(options: [.alert, .sound, .badge])
|
||||
@@ -60,7 +58,14 @@ class NotificationManager: NSObject, NotificationManagerProtocol {
|
||||
}
|
||||
|
||||
func register(with deviceToken: Data) async -> Bool {
|
||||
await setPusher(with: deviceToken, clientProxy: clientProxy)
|
||||
guard let clientProxy else {
|
||||
return false
|
||||
}
|
||||
return await setPusher(with: deviceToken, clientProxy: clientProxy)
|
||||
}
|
||||
|
||||
func setClientProxy(_ clientProxy: ClientProxyProtocol?) {
|
||||
self.clientProxy = clientProxy
|
||||
}
|
||||
|
||||
func registrationFailed(with error: Error) { }
|
||||
|
||||
Reference in New Issue
Block a user