TrioWatchApp.swift 533 B

123456789101112131415161718192021222324
  1. import SwiftUI
  2. import UserNotifications
  3. @main struct TrioWatchApp: App {
  4. @Environment(\.scenePhase) private var scenePhase
  5. init() {
  6. WatchNotificationHandler.shared.configure()
  7. }
  8. var body: some Scene {
  9. WindowGroup {
  10. TrioMainWatchView()
  11. }
  12. .onChange(of: scenePhase) { _, newScenePhase in
  13. if newScenePhase == .background {
  14. Task {
  15. await WatchLogger.shared.flushPersistedLogs()
  16. }
  17. }
  18. }
  19. }
  20. }