[iOS] 화면캡쳐감지, 화면녹화감지 체크하기
안녕하세요 물먹고하자 입니다 :)
저번에 이어서 공공기관용 배포준비중 화면캡쳐감지, 화면녹화감지도 기능개발을 해야해서
사전에 알아보고 있는중입니다. MDM을 사용하면 되기야 하겠지만, 그정도의 제어는 아닌
해당사용자가 캡쳐, 화면녹화를 어디에서 하고 있다만 알면 된다고 하더군요.
추가로 개발은 필요할것 같으나 화면캡쳐, 녹화 감지하는 Notification 공유드립니다.
1. 감지 Notification 알아보기
💡 화면캡쳐감지, 화면녹화감지 Notification
- 화면녹화감지 : UIScreen.capturedDidChangeNotification
- 캡쳐감지 : UIApplication.userDidTakeScreenshotNotification
참고 : 화면녹화 감지시에는 시작전알림이 와서 화면을 블러처리 가능함. 화면캡쳐시는 했다고만 알림이옴
샘플 예시로 저는 저번 작업했던 [iOS] 화면 백그라운드 이동시 블러 처리하기 (sceneWillResignActive Screen Blur) 활용해서 동영상감지시에는 블러처리까지 해보았습니다.
2. SceneDelegate 코드 적용
💡참고 SceneDelegate 함수 활용하여 화면녹화 감지시 Blur 처리를 추가해봤습니다.
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
var blurView: UIVisualEffectView?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let _ = (scene as? UIWindowScene) else { return }
// 화면 녹화 감지시
NotificationCenter.default.addObserver(
self,
selector: #selector(recodingAction),
name: UIScreen.capturedDidChangeNotification,
object: nil
)
// 화면 캡쳐시
NotificationCenter.default.addObserver(
self,
selector: #selector(captureAction),
name: UIApplication.userDidTakeScreenshotNotification,
object: nil
)
}
deinit {
NotificationCenter.default.removeObserver(self)
}
// 캡쳐시 실행되는 액션 메소드
@objc private func recodingAction() {
if UIScreen.main.isCaptured {
// 캡쳐 중이면 = 화면 녹화 중이면
guard let window = window else {
return
}
let effect = UIBlurEffect(style: .regular)
blurView = UIVisualEffectView(effect: effect)
blurView?.frame = window.frame
window.addSubview(blurView!)
let alert = UIAlertController(title: "알림", message: "녹화가 감지되엇다!!!!", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "확인", style: .default))
window.rootViewController?.present(alert, animated: true)
} else {
// 캡쳐 중이 아니면 = 화면 녹화가 끝
if let blurView = blurView {
blurView.removeFromSuperview()
}
}
}
...(중략)...
}
마무리
아직 캡쳐감지와 화면녹화감지 기능을 적용해서 배포 한건 아니고 알아보고 있는중입니다.
화면녹화는 블러처리나 로고이미지로 덮어버려서 막는게 가능할것 같은데,
문제는 캡쳐기능이네요. 네이버웹툰, 카카오뱅크 등 캡쳐하시면 기능을 막은게 아니라 감지밖에 안되는 이유가 있었군요.
지금 생각에는 textField .secure(비밀번호입력때 쓰는거) 활용해서 캡쳐 자체의 내용을 안나오게 하는 예시들을 보긴봤는데
이미 개발된 500~600벌 화면에 적용을 노가다로 할순없고, UIView 상속받는 위치에 적용해보는 테스트를 해봐야할 것 같습니다.
UIKit, SwiftUI 혼합이라 적용이 잘될 것 같진 않네요.
오늘은 이만~
즐거운 코딩 되게요.
끝.
댓글
댓글 쓰기