SwiftUI: How to detect if the application in background or foreground?

How to use scenePhase to detect scene state? — iOS 14 — XCode 12

Different ways to get scene phase and App phase