我想在手表应用程序进入前台时收到通知。如何在 SwiftUI 中注册“willEnterForegroundNotification”。以下是在 UIKit 中注册相同的代码。
Text("Hello, World!")
.onReceive(NotificationCenter.default.publisher(for: UIApplication.willEnterForegroundNotification)) { _ in
print("Moving back to the foreground!")
}