Secure .NET MAUI application

Secure .NET MAUI application

06 August 2022

.NET MAUI/Xamarin

Buy Me A Coffee

If you are developing secure mobile applications like Bank apps or Health apps you probably want to safeguard their content on non-secure displays (on minimizing or on screenshot capture).

Likely both Android and iOS/MacCatalyst allow us to protect our apps.

Let's start with Android.

Android uses the mechanism of flags which can be set to Window.

We need a flag called FLAG_SECURE. FLAG_SECURE can be placed on a Window to indicate that the contents of this Window don’t want to be recorded.

From theory to practice.

To achieve the result we need to override 2 methods in MainActivity:

We set the flag when our application is paused and remove the flag when it becomes active.

On iOS/MacCatalyst the idea is similar.

We need to add a subview to our KeyWindow. It can be any UIView. In this sample to make it similar to the Android implementation let's use UIVisualEffectView with the Blur effect.

We add the overlay view on resign activation and remove it on the app activated.

As a result, you should receive such app:

Android secure

The full code can be found on GitHub.

Happy coding!

Buy Me A Coffee

Related:

Adding custom action button to .NET MAUI Shell TabBar

The article demonstrates how to customize .NET MAUI Shell TabBar for Android and iOS/MacCatalyst platforms, offering step-by-step guidance, code examples, and a link to the GitHub repository containing full examples for practical usage.

Simplifying .NET MAUI App Development with Debugging and Monitoring Tools

Simplifying .NET MAUI App Development: Debugging and Monitoring Tools.

An unhandled error has occurred. Reload

🗙