Secure your iOS app's sensitive data by preventing screenshots and protecting background app snapshots with ease.
- πΈ Screenshot Prevention - Detect and handle screenshot attempts
- πΌοΈ Custom Background Protection - Replace app preview with custom content
- π¨ Multiple Protection Styles:
- Blur effect
- Custom image
- Solid color
- π¬ Screen Recording Detection - Know when screen is being recorded
- π Easy Integration - Simple API with clear documentation
- π¦ Multiple Installation Options - CocoaPods and Swift Package Manager support
Add to your Podfile
:
pod 'ScreenProtectorKit'
Then run:
pod install
Add to your Package.swift
:
let package = Package(
dependencies: [
.package(url: "https://github.com/prongbang/ScreenProtectorKit.git", from: "1.3.1"),
],
)
Or via Xcode:
- File β Add Packages...
- Enter package URL:
https://github.com/prongbang/ScreenProtectorKit.git
- Select version:
1.3.1
or later
import ScreenProtectorKit
class AppDelegate: FlutterAppDelegate {
private lazy var screenProtectorKit = {
return ScreenProtectorKit(window: window)
}()
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// Configure screenshot prevention
screenProtectorKit.configurePreventionScreenshot()
return true
}
}
Detect and respond to screenshot attempts:
override func applicationDidBecomeActive(_ application: UIApplication) {
screenProtectorKit.enabledPreventScreenshot()
}
override func applicationWillResignActive(_ application: UIApplication) {
screenProtectorKit.disablePreventScreenshot()
}
Apply blur effect when app goes to background:
override func applicationDidBecomeActive(_ application: UIApplication) {
screenProtectorKit.disableBlurScreen()
}
override func applicationWillResignActive(_ application: UIApplication) {
screenProtectorKit.enabledBlurScreen()
}
Show custom image when app is in background:
override func applicationDidBecomeActive(_ application: UIApplication) {
screenProtectorKit.disableImageScreen()
}
override func applicationWillResignActive(_ application: UIApplication) {
screenProtectorKit.enabledImageScreen(named: "LaunchImage")
}
Display solid color when app is in background:
override func applicationDidBecomeActive(_ application: UIApplication) {
screenProtectorKit.disableColorScreen()
}
override func applicationWillResignActive(_ application: UIApplication) {
screenProtectorKit.enabledColorScreen(hexColor: "#ffffff")
}
Check if screen is being recorded:
let isRecording = screenProtectorKit.screenIsRecording()
if isRecording {
// Handle screen recording scenario
}
import ScreenProtectorKit
class AppDelegate: FlutterAppDelegate {
private lazy var screenProtectorKit = {
return ScreenProtectorKit(window: window)
}()
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// Setup screenshot prevention
screenProtectorKit.configurePreventionScreenshot()
// Handle screen recording if needed
if screenProtectorKit.screenIsRecording() {
showRecordingWarning()
}
return true
}
override func applicationDidBecomeActive(_ application: UIApplication) {
// Enable screenshot prevention
screenProtectorKit.enabledPreventScreenshot()
// Remove protection overlay
screenProtectorKit.disableBlurScreen()
}
override func applicationWillResignActive(_ application: UIApplication) {
// Disable screenshot prevention
screenProtectorKit.disablePreventScreenshot()
// Add protection overlay
screenProtectorKit.enabledBlurScreen()
}
private func showRecordingWarning() {
// Show alert to user about screen recording
}
}
- Screenshot prevention on iOS works by detecting attempts, not blocking them entirely
- Background protection helps prevent data leaks in app switcher
- Screen recording detection only indicates if recording is in progress
- Test thoroughly across different iOS versions and devices
- iOS 13.0+
- Swift 5.5+
- Xcode 13.0+
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
If you find this package helpful, please consider supporting it: