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:

Drag and Drop any content to a .NET MAUI application

The article demonstrates how to add drop functionality to easily move content from the operating system to the .NET MAUI application.

Creating Markdown control with .NET MAUI Graphics

The article demonstrates how to render markdown with .NET MAUI Graphics.

An unhandled error has occurred. Reload

🗙