From 2fa4a2f42206f34b0f87aa984b4543377613e1f8 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Mon, 1 Apr 2024 14:31:36 +0300 Subject: [PATCH] FIxes #2602 - Fix pushers not being registered on re-login after recent Onboarding changes --- .../Notification/Manager/NotificationManager.swift | 13 ++++++++++++- changelog.d/2602.bugfix | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 changelog.d/2602.bugfix diff --git a/ElementX/Sources/Services/Notification/Manager/NotificationManager.swift b/ElementX/Sources/Services/Notification/Manager/NotificationManager.swift index fa7a7a5edc..37d175f935 100644 --- a/ElementX/Sources/Services/Notification/Manager/NotificationManager.swift +++ b/ElementX/Sources/Services/Notification/Manager/NotificationManager.swift @@ -23,7 +23,18 @@ final class NotificationManager: NSObject, NotificationManagerProtocol { private let notificationCenter: UserNotificationCenterProtocol private let appSettings: AppSettings - private var userSession: UserSessionProtocol? + private var userSession: UserSessionProtocol? { + didSet { + // If notification permissions were given previously then attempt re-registering + // for remote notifications on startup. Otherwise let the onboarding flow handle it + Task { @MainActor in + if await self.notificationCenter.authorizationStatus() == .authorized { + self.delegate?.registerForRemoteNotifications() + } + } + } + } + private var cancellables = Set() private var notificationsEnabled = false diff --git a/changelog.d/2602.bugfix b/changelog.d/2602.bugfix new file mode 100644 index 0000000000..7ddc99da75 --- /dev/null +++ b/changelog.d/2602.bugfix @@ -0,0 +1 @@ +Fix pushers not being registered on re-login after recent Onboarding changes \ No newline at end of file