Immersive scene phases

Immersive scene phases
Photo by v2osk / Unsplash

Observing the ScenePhase in the environment has demonstrated to be a far more reliable technique for determining if an ImmersiveSpace is active or not. This is particularly helpful for making accessibility announcements, as it allows the user to adjust to the context switch.

import SwiftUI

@main
struct ImmersiveScenePhaseApp: App {
  @Environment(\.scenePhase) var scenePhase

  var body: some Scene {
    WindowGroup {
      ContentView()
    }

    ImmersiveSpace(id: "ImmersiveSpace") {
      ImmersiveView()
    }
    .onChange(of: scenePhase) { _, newPhase in
      var scenePhaseDescription = AttributedString("ImmersiveSpace \(newPhase)")
      scenePhaseDescription.accessibilitySpeechAnnouncementPriority = .high

      switch newPhase {
        case .active:
          AccessibilityNotification.Announcement(scenePhaseDescription).post()

        case .inactive:
          AccessibilityNotification.Announcement(scenePhaseDescription).post()

        default:
          break
      }
    }
  }
}

Basic demonstration built on top of the basic Xcode template

🙏
Thank you @Harlan for pointing this up
Pageview analytics comparison

We are comparing self-hosted OpenPanel with the analytics already used on this site. This comparison records page paths, referring website origins, pageview times, random event IDs, browser and device information, and approximate location. Our server processes IP and browser information to generate rotating, pseudonymous visitor IDs. OpenPanel does not use tracking cookies or save a visitor ID in your browser. URL queries, fragments and page titles are removed; click tracking and session replay are off.

Do Not Track and Global Privacy Control disable this OpenPanel comparison. If you change the choice below, only that preference is saved in your browser. Existing analytics remain active during the comparison. Contact and site information.