4

To some reasons, our APP dont't want people record screen, but in ios11 a new feature can let user record there iphone screen, so is there an API or notification indicate me user is recording now thank u very much

Wong Sam
  • 347
  • 3
  • 9

2 Answers2

7

You can detect if the screen is being recorded with:

UIScreen.main.isCaptured
// True if this screen is being captured (e.g. recorded, AirPlayed, mirrored, etc.)

You can't prevent it using project settings, but you could use a modal or something to request the user to disable it. Not sure how that might workout with your AppStore submission.

nathan
  • 9,329
  • 4
  • 37
  • 51
  • This is not only screen capture but also mirroring with airplay. So not the exact solution. – birdcage Sep 14 '17 at 12:03
  • I know, that's why I added a comment to reflect it – nathan Sep 14 '17 at 15:15
  • It's worth noting that I have seen this value return an incorrect result multiple times in testing. Frequently, we encounter a bug where the we *are* using screen recording but isCaptured returns false. – FateNuller Sep 29 '17 at 15:05
  • 1
    how can i detect for below ios 11?? – Amrit Tiwari Jan 08 '18 at 05:31
  • @WongSam if this is the correct answer that solves your problem, don't forget to accept it (green tick is) ;) – Ahmad F Apr 26 '18 at 06:47
  • if UIScreen.main.isCaptured is true, then How to Stop that record? I have start screen record, by pressing RECORD button from CONTROL CENTER, then immediately, if I open my app, then I have to STOP that record programmatically. – McDonal_11 Apr 09 '19 at 17:36
0

You can use kvo observe UIScreenCapturedDidChangeNotification in iOS 11 like this

NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
    [[NSNotificationCenter defaultCenter] addObserverForName:UIScreenCapturedDidChangeNotification object:nil queue:mainQueue usingBlock:^(NSNotification * _Nonnull note) { 
 //code you want execute
}];
SilverNak
  • 3,283
  • 4
  • 28
  • 44
李国立
  • 31
  • 1
  • 5