Secure .NET MAUI application
Apps that show sensitive data, like banking or health apps, often need to safeguard their content when the app is minimized or a screenshot is captured. This post covers a platform-specific approach for each side.
On Android, the answer is FLAG_SECURE on the window. In MainActivity, OnPause sets WindowManagerFlags.Secure and OnResume clears it, so the content is protected whenever the app isn’t active. On iOS and MacCatalyst, the idea is similar but uses a view. OnResignActivation adds a UIVisualEffectView with a blur effect to the key window, tags it, and OnActivated removes it again.
Each snippet is short enough to drop into an existing app, and the full code is on GitHub.