Featured
App Switcher Snapshot Controls
Hide Sensitive Information in App Switcher
In iOS, the App Switcher Snapshot Control is how iOS captures and shows a screenshot of an app when you switch between apps or go back to the home screen. But if your app shows sensitive information like users’ financial details or health records, should you risk showing that in the app switcher? We’ll figure out how to keep that info private. Let’s get started!
Let’s say we have a view that displays some personal information about a user. This information will be visible when the user is using screenshare or navigating between apps using the app switcher. Take a look at the screenshot below. We’ve created a view that’s visible when the user switches to another app. But notice that the user’s personal information screen is still there, even if the app they’re currently using comes to the top of the switcher. However, for certain types of apps, it’s crucial to keep the user’s information safe and secure.
To handle this, we can use the lifecycle API to check if the application is active or inactive. If it’s active, it means the user is currently using the app. In that case, we can remove the overlay we place when the app goes into the background and the user tries to use the app switcher. We can add an overlay over the window so that if the user is using the app switcher, we can display some overlay or any view on top of main window. See the code below.
struct AppSwitcherDemoApp: App {
@Environment(\.scenePhase) private var scenePhase
var body: some Scene {
WindowGroup {
ContentView()
.onChange(of: scenePhase) { newPhase in
if newPhase == .inactive {
if let window = UIApplication.shared.connectedScenes
.compactMap({ $0 as? UIWindowScene })
.first?.windows.first {
let blurEffect = UIBlurEffect(style: .light)
let blurView = UIVisualEffectView(effect: blurEffect)
blurView.frame = window.bounds
blurView.tag = 222
window.addSubview(blurView)
}
} else if newPhase == .active {
if let window = UIApplication.shared.connectedScenes
.compactMap({ $0 as? UIWindowScene })
.first?.windows.first {
window.viewWithTag(222)?.removeFromSuperview()
}
}
}
}
}
}
And here’s the desired result below.
You should suggest/ask your customers if their apps fall into any of the following categories:
Banking apps: These apps must enable this feature to prevent unauthorized access to users’ banking information.
Health Info apps: We should implement this feature to safeguard user data from potential leaks.
Crypto wallets and stock apps: These apps also fall under this category, as users may not want their financial information to be visible to others.
Password managers and message apps: These apps can also be vulnerable to data breaches, so we should implement this feature to protect user data.
This little feature, along with others, will help you take your app’s security to the next level. So don’t forget to add this functionality for your app…☺️
That’s all for now! Thanks so much for taking the time to read my post. I really value your feedback. If you found it helpful, please give it a clap or leave a comment. I’ll see you in the next one! 🙌