From aad09b42099319bf6a18ff8c78344397c33a3f90 Mon Sep 17 00:00:00 2001 From: kaira Diagne Date: Fri, 18 Dec 2020 12:44:01 +0100 Subject: [PATCH 1/2] Fix spelling mistake --- Sources/UINotificationCenter.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/UINotificationCenter.swift b/Sources/UINotificationCenter.swift index 3a9fb9b..5e16d22 100644 --- a/Sources/UINotificationCenter.swift +++ b/Sources/UINotificationCenter.swift @@ -31,7 +31,7 @@ public final class UINotificationCenter { // MARK: Private properties /// The window which will be placed on top of the application window. - /// This window is used to present the notifications on and will be hided when all notifications are presented. + /// This window is used to present the notifications on and will be hidden when all notifications are presented. internal let window: UIWindow /// Handles queueing of all notifications. Contains a queue of `UINotificationRequest` objects. From be26c30a2e413dc1549734987a9c67da6caed314 Mon Sep 17 00:00:00 2001 From: kaira Diagne Date: Fri, 18 Dec 2020 12:48:56 +0100 Subject: [PATCH 2/2] Make the window visible without it becoming the key window of the app. For the presentation of notifications the window does not have to be key. It will still receive touch events (gestures, buttons etc) but won't receive keyboard events and motion events. --- Sources/UINotificationCenter.swift | 2 +- Sources/UINotificationPresentationContext.swift | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Sources/UINotificationCenter.swift b/Sources/UINotificationCenter.swift index 5e16d22..007be97 100644 --- a/Sources/UINotificationCenter.swift +++ b/Sources/UINotificationCenter.swift @@ -31,7 +31,7 @@ public final class UINotificationCenter { // MARK: Private properties /// The window which will be placed on top of the application window. - /// This window is used to present the notifications on and will be hidden when all notifications are presented. + /// This window is used to present the notifications on and will be hidden when notifications are dismissed. internal let window: UIWindow /// Handles queueing of all notifications. Contains a queue of `UINotificationRequest` objects. diff --git a/Sources/UINotificationPresentationContext.swift b/Sources/UINotificationPresentationContext.swift index e5f5be8..8d4e13a 100644 --- a/Sources/UINotificationPresentationContext.swift +++ b/Sources/UINotificationPresentationContext.swift @@ -52,7 +52,7 @@ public final class UINotificationPresentationContext { private func prepareContainerWindow() { containerWindow.windowLevel = windowLevel #if !TEST - containerWindow.makeKeyAndVisible() + containerWindow.isHidden = false #endif } @@ -94,9 +94,6 @@ public final class UINotificationPresentationContext { /// Move the window behind the key application window. containerWindow.windowLevel = UIWindow.Level.normal - 1 containerWindow.rootViewController = nil - - /// Make sure the key window of the app is visible again. - guard let applicationWindow = UIApplication.shared.windows.first(where: { $0 != self.containerWindow }) else { return } - applicationWindow.makeKeyAndVisible() + containerWindow.isHidden = true } }