Swift/기타
[SWIFT]스크린 캡쳐 및 녹화 감지
삽질중
2023. 4. 26. 08:43
스크린 캡쳐 또는 녹화가 시작되면 Notification 호출
: 캡쳐나 녹화 한다는건 알 수 있지만 실제 스크린샷을 막지는 못한다. 스크린샷이 찍힌 후에 호출되는거 같다.
NotificationCenter.default.addObserver(
self,
selector: #selector(screenshotCapture),
name: UIApplication.userDidTakeScreenshotNotification,
object: nil
)
NotificationCenter.default.addObserver(
self,
selector: #selector(screenRecoding),
name: UIScreen.capturedDidChangeNotification,
object: nil
)
@objc func screenshotCapture() {
// 스크린샷 캡쳐 노티 함수
}
@objc func screenRecoding() {
// 스크린샷 시작 및 종료시 둘다 호출되므로 isCaptured로 녹화 종료시에는 리턴
guard UIScreen.main.isCaptured else {
return
}
// 스크린 녹화 노티 함수
}