Introduction
When your app is open and running, it needs to show notifications differently than when it is closed. Handling notifications in the foreground means your app can decide how to show alerts or messages while the user is actively using it.
When you want to show a custom alert or message inside the app while the user is using it.
When you want to update the app's screen immediately after receiving a notification.
When you want to prevent the default system notification from showing while the app is open.
When you want to log or track notifications received during active app use.
When you want to play a sound or vibrate the device only when the app is in the foreground.