Ios Detection of Screenshot

iOS Detection of Screenshot?

I found the answer!! Taking a screenshot interrupts any touches that are on the screen. This is why snapchat requires holding to see the picture. Reference: http://tumblr.jeremyjohnstone.com/post/38503925370/how-to-detect-screenshots-on-ios-like-snapchat

Unable to detect screenshot in simulator

Work fine with Xcode 12.5.1 and seems like you are taking screenshot direct from the save screen button. The save screen button is not a screenshot button.

Take a screenshot from this command

Device -> Trigger Screenshot

Sample Image

SwiftUI detect when the user takes a screenshot or screen recording

Here is a simple demo:

struct ContentView: View {
@State var isRecordingScreen = false

var body: some View {
Text("Test")
.onReceive(NotificationCenter.default.publisher(for: UIApplication.userDidTakeScreenshotNotification)) { _ in
print("Screenshot taken")
}
.onReceive(NotificationCenter.default.publisher(for: UIScreen.capturedDidChangeNotification)) { _ in
isRecordingScreen.toggle()
print(isRecordingScreen ? "Started recording screen" : "Stopped recording screen")
}
}
}


Related Topics



Leave a reply



Submit