Skip to content

Commit

Permalink
Mapping willConnectNotification notification (sent in iOS 15) to tr…
Browse files Browse the repository at this point in the history
…ansition from .background to .inactive (or do nothing if we are already active).
  • Loading branch information
pd95 committed Feb 13, 2022
1 parent 199791f commit d49244c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion SwiftUIShim/Utilities/SceneManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class SceneManager: ObservableObject {

// The cancellables used when setting up the scene activity monitoring
private var cancellables = Set<AnyCancellable>()
@Published var scenePhase = ScenePhase.inactive
@Published var scenePhase = ScenePhase.background

public init(_ scene: UIScene, store: [AnyHashable: Any]?) {
print("🟢 SceneManager.init", "sceneIdentifier", scene.session.persistentIdentifier)
Expand Down Expand Up @@ -99,6 +99,10 @@ public class SceneManager: ObservableObject {
scenePhase = .active
case UIScene.willEnterForegroundNotification, UIScene.willDeactivateNotification:
scenePhase = .inactive
case UIScene.willConnectNotification:
if scenePhase == .background {
scenePhase = .inactive
}
case UIScene.didEnterBackgroundNotification:
scenePhase = .background
default:
Expand Down

0 comments on commit d49244c

Please sign in to comment.