Tuesday, June 14, 2016

Screenshot notification in Objective C

If our app is displaying delicate/private data where user is not allowed to download our files, Users may go for taking the screenshot of that file. We may need to know whether there is any screenshot taken from our iOS app. This feature is available in some chat applications available in market today. When user takes the screenshot of the sent pic from another user, the other user will get notified of this.

We have a notification which was introduced in iOS7 which is posted after user takes a screenshot.

That is UIApplicationUserDidTakeScreenshotNotification.


In your ViewController, Where you display your private data, You can observe for this notification.



  [[NSNotificationCenter defaultCenteraddObserver:self 
                                 selector:@selector(screenshotTaken:) 
                       name:UIApplicationUserDidTakeScreenshotNotification 
                object:nil];

   -(void)screenshotTaken:(NSNotification*)note{
    
          NSLog(@"screenshotTaken");
    
    }



Hope this post is useful. Feel free to comment in case of any queries.





No comments:

Post a Comment