1

In an app I'm creating, you're not allowed to take screenshots. I was wondering how you could detect and block screenshots. I found out you could do that using ShotBlocker, but I don't know how. Does anyone know how you can detect and block screenshots in Objective-C?

Developer
  • 406
  • 1
  • 4
  • 18

1 Answers1

1

There is no way to block a screenshot on iOS. At least you can detect the screenshot after it was taken in that way:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(screenshotDetected) name:UIApplicationUserDidTakeScreenshotNotification object:nil];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];

    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationUserDidTakeScreenshotNotification object:nil];
}

- (void)screenshotDetected {

    UIAlertView * alert =[[UIAlertView alloc ] initWithTitle:@"Hey!"
                                                     message:@"You're not allowed to do that"
                                                    delegate:self
                                           cancelButtonTitle:@"Cancel"
                                           otherButtonTitles: nil];
    [alert addButtonWithTitle:@"GO"];
    [alert show];
}
itinance
  • 11,711
  • 7
  • 58
  • 98