blob: f7cd15eda8e2aba189bf0d187e3319bff41003a3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
//
// DomainDigApp.swift
// DomainDig
//
// Created by cmc on 2026-03-10.
//
import SwiftUI
@main
struct DomainDigApp: App {
@Environment(\.scenePhase) private var scenePhase
@AppStorage(AppDensity.userDefaultsKey) private var density = AppDensity.compact.rawValue
@State private var viewModel = DomainViewModel()
@State private var purchaseService = PurchaseService.shared
init() {
LocalNotificationService.shared.configureForegroundPresentation()
DomainMonitoringScheduler.shared.registerBackgroundTask()
}
var body: some Scene {
WindowGroup {
RootTabView(viewModel: viewModel)
.environment(\.appDensity, AppDensity(rawValue: density) ?? .compact)
.task {
let _ = purchaseService.currentTier
await purchaseService.refreshEntitlements()
viewModel.refreshMonitoringState()
await viewModel.refreshMonitoringAuthorizationStatus()
viewModel.monitoringStatusMessage = DomainMonitoringScheduler.shared.syncSchedule()
}
}
.onChange(of: scenePhase) { _, newValue in
guard newValue == .active else { return }
viewModel.refreshMonitoringState()
Task {
await viewModel.refreshMonitoringAuthorizationStatus()
}
viewModel.monitoringStatusMessage = DomainMonitoringScheduler.shared.syncSchedule()
}
}
}
|