iOS Detect Screenshot
It will be triggered when user take screenshot's.
func detectScreenShot(action: @escaping () -> ()) {
//Creating in main Queue
let mainQueue = OperationQueue.main
NotificationCenter.default.addObserver(forName: UIApplication.userDidTakeScreenshotNotification, object: nil, queue: mainQueue) { notification in
// Executes after ScreenShot
action()
}
}
Just call like
When ever we add observer we have to remove. Don't forget to remove.
We can't restrict user to take screenshot. If you found best way let me know.
Note: Try in iPhone device for best result.
Let's grow together 🌱
Cheers 🍻