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:
The full code can be found on GitHub.
Happy coding!