Detect Screenshots in Objective-C

A number of social apps are trending in App Store now a days. Where user upload his profile pics and share moments. But due to a capture option provided by iPhone , anyone can take screenshots of your profile picture without notice by you and share anywhere.

So removing such glitch or capture your image by unknown, Snapchat first introduce feature to notify you whenever anyone take screenshot of your profile.
So how they do that ? lets focus on coding part.

In iOS 7 , if developer need to know or detect screenshots in your application then he have to used touchesCancelled:withEvent: , but now its unavailable Due to which capture notify method of snapchat stop working and no longer support.
So apple introduce new feature in replacement of touchesCancelled:withEvent: with NSNotificationCenter to add an observer UIApplicationUserDidTakeScreenshotNotification.

Below code is used to detect Screenshots in Objective-C

NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationUserDidTakeScreenshotNotification object:nil queue:mainQueue usingBlock:^(NSNotification *note)
// add your code after screenshot is taken to notify your user by registered device either push notification or by making a section



Add a Comment

Your email address will not be published. Required fields are marked *