From 51bed9e1fce31eff93769be20cfa75857861c513 Mon Sep 17 00:00:00 2001 From: Shannon Young Date: Wed, 29 Sep 2021 12:35:39 -0700 Subject: [PATCH] Clear notifications on log out --- .../Sources/BridgeClientUI/BridgeClientAppManager.swift | 1 + .../Sources/BridgeClientUI/LocalNotificationManager.swift | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/SwiftPackage/Sources/BridgeClientUI/BridgeClientAppManager.swift b/SwiftPackage/Sources/BridgeClientUI/BridgeClientAppManager.swift index 6b2dede8f..7c5dd2b2f 100644 --- a/SwiftPackage/Sources/BridgeClientUI/BridgeClientAppManager.swift +++ b/SwiftPackage/Sources/BridgeClientUI/BridgeClientAppManager.swift @@ -142,6 +142,7 @@ open class BridgeClientAppManager : ObservableObject { } public func signOut() { + localNotificationManager.clearAll() authManager.signOut() isOnboardingFinished = false userSessionInfo = nil diff --git a/SwiftPackage/Sources/BridgeClientUI/LocalNotificationManager.swift b/SwiftPackage/Sources/BridgeClientUI/LocalNotificationManager.swift index 6d947c7dd..f1890bcbb 100644 --- a/SwiftPackage/Sources/BridgeClientUI/LocalNotificationManager.swift +++ b/SwiftPackage/Sources/BridgeClientUI/LocalNotificationManager.swift @@ -152,6 +152,11 @@ open class LocalNotificationManager : NSObject, UNUserNotificationCenterDelegate return requests } + public func clearAll() { + removeAllPendingNotifications() { + } + } + private func removeAllPendingNotifications(_ completionHandler: @escaping (() -> Void)) { UNUserNotificationCenter.current().getPendingNotificationRequests { (requests) in let requestIds: [String] = requests.compactMap {