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 Application Insights to .NET MAUI Application

This article provides an in-depth exploration into how you can integrate Microsoft's Application Insights into your .NET MAUI application. A comparative study between Microsoft AppCenter and Application Insights is also highlighted, demystifying the inherent advantage of Application Insights in application management and analytics.

Migrate the deprecated OnBackPressed function in .NET MAUI Android application

This article is devoted to the new API added in Android 13, that adds support to predictive back gestures.

An unhandled error has occurred. Reload

🗙