How do I know if screen recorder is Turned ON.

My applicaiton requires content not to be copied, and I have already blocked it from Ariplay/HDMi, Quicktime, but how do I stop it form screen recorder on iOS 11. I need a wasy to detect if screen recording is turned ON from control center.... Please help...

Answered by RyotzIwatz in 247434022

Use this UIScreen's new propertiy in iOS11 beta 4 `isCaptured`.

https://developer.apple.com/documentation/uikit/uiscreen/2921651-iscaptured

It is works well in beta4.

i have the same problem...still waiting for solution...

When screen recorder is turned on, it should be like this in control center: http://imgur.com/a/EVF0n (icon should be red while recording). Hope I could help you!

Apple’s engineers confirmed to me that there is a solution already:


1. Listen to the following notifications: UIScreenDidConnectNotification, UIScreenDidDisconnectNotification and UIScreenModeDidChangeNotification 2. When any of them fire, iterate through [UIScreen screens] and see if any of them have the mirroredScreen property set to YES as a way to detect if a user has activated iOS 11 screen recording


This was in response to my bug report,

32721460.

How to know UIScreen is screen recroding's screen or other mirrored screen (e,g. AirPlay)

I try to detect [UIScreen screens] on iOS11 iPhone, iPad.


In iPhone is well detect.


But i found iPad has different result :

non of them in [UIScreen screens] has mirroredScreen property (screen.mirroredScreen == nil)

you can determind by


CGSizeEqualToSize(mirrorScreen.currentMode.size, screen.currentMode.size)


if it's mirroring, they will have same size

In iOS 11 beta 3 there is no change in `UIScreen.screens`.

I have used the screen size methods to check if screen recording is in progress on iOS11 beta2, and it works.

However, it failed to detect screen recording actions on iOS11 beta3.


Don't know if Apple will fix this issue in iOS11 beta4 or offer another solution.

UIScreenDidConnectNotification, UIScreenDidDisconnectNotification and UIScreenModeDidChangeNotification are no longer working now with iOS11 Beta 3. Any other workaounds now..

UIScreenDidConnectNotification, UIScreenDidDisconnectNotification and UIScreenModeDidChangeNotification are no longer working now with iOS11 Beta 3. Any other workarounds now..

Did someone found any solution to it yet...

Accepted Answer

Use this UIScreen's new propertiy in iOS11 beta 4 `isCaptured`.

https://developer.apple.com/documentation/uikit/uiscreen/2921651-iscaptured

It is works well in beta4.

The property "isCaptured" is including mirrored and airplay.


Is there anyway to make sure the device is recording?

I checked this in iOS beta 4 and this is for screen recording and airplay mirror as well.

I am able to capture the event for recording start and end. I added the KVO in "captured" property.


@property(nonatomic,readonly,getter=isCaptured) BOOL captured NS_AVAILABLE_IOS(11_0); // True if this screen is being captured (e.g. recorded, AirPlayed, mirrored, etc.)



UIScreen *mainScreen = [UIScreen mainScreen];

[mainScreen addObserver:self forKeyPath:@"captured" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:NULL];



-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{


AVAudioSession* audioSession = [AVAudioSession sharedInstance];

AVAudioSessionRouteDescription* currentRoute = audioSession.currentRoute;

for (AVAudioSessionPortDescription* outputPort in currentRoute.outputs){

if ([outputPort.portType isEqualToString:AVAudioSessionPortAirPlay]){

NSLog(@"%@",outputPort.portName);

NSLog(@"%@",outputPort.portType);

return;

}

}


if ([keyPath isEqualToString:@"captured"]) {

id oldC = [change objectForKey:NSKeyValueChangeOldKey];

id newC = [change objectForKey:NSKeyValueChangeNewKey];

NSLog(@"%d %d", [oldC boolValue], [newC boolValue]);

if (newC) {

/

}

}

}

Yeah, that property is really useful. But I still want to build my codebase with Xocde8 (i.e. old binaries), because shifting to new Xcode would bring me more changes to take care. Any solutions?

I have found 1 soultion:

https://medium.com/swiftist/how-to-use-ios-11-beta-installed-device-with-xcode-8-c255b916aca5


But not sure, about its side effects. Any pointer/drawbacks of this approach?

How do I know if screen recorder is Turned ON.
 
 
Q