-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathiOSApp.swift
More file actions
33 lines (30 loc) · 897 Bytes
/
iOSApp.swift
File metadata and controls
33 lines (30 loc) · 897 Bytes
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
//
// iOSApp.swift
// iOS
//
// Created by Fernando Bunn on 28/01/2025.
//
import SwiftUI
import WidgetKit
@main
struct iOSApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.onReceive(NotificationCenter.default.publisher(for: UIApplication.didEnterBackgroundNotification)) { _ in
updateAllWidgets()
}
.onReceive(NotificationCenter.default.publisher(for: UIApplication.willEnterForegroundNotification)) { _ in
updateAllWidgets()
}
.onReceive(NotificationCenter.default.publisher(for: UIApplication.didBecomeActiveNotification)) { _ in
updateAllWidgets()
}
}
}
private func updateAllWidgets() {
Task {
WidgetCenter.shared.reloadAllTimelines()
}
}
}