How to disable screen Recording in iOS app

我的梦境 提交于 2020-06-24 13:45:18

问题


Is there any way to disable the screen recording? or is is possible through a configuration profile? or any third party library is available?


回答1:


NotificationCenter.default.addObserver(self, selector: #selector(preventScreenRecording), name: NSNotification.Name.UIScreenCapturedDidChange, object: nil)

And create a view inside main view and prevent like that.

(void) preventScreenRecording {
if (@available(iOS 11.0, *)) {
    BOOL isCaptured = [[UIScreen mainScreen] isCaptured];

    if (isCaptured) {
        self.blockView.hidden = false;
    }
    else {
        self.blockView.hidden = true;
    }
}



回答2:


When your app is started you can test UIScreen.isCaptured property and show some splash screen if it's set to true.

You should also observe (subscribe in some place for) capturedDidChangeNotification notification, and do same thing (show splash screen) if UIScreen.isCaptured is set to true.




回答3:


sharedRecorder.stopRecording( handler: { previewViewController, error in    
    if let error = error {
        print("\(error.localizedDescription)")
    }
    if UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.pad {
        previewViewController?.modalPresentationStyle = UIModalPresentationStyle.popover
        previewViewController?.popoverPresentationController?.sourceRect = CGRect.zero
        previewViewController?.popoverPresentationController?.sourceView = self.view
    }
    if previewViewController != nil {
        self.previewViewController = previewViewController
        previewViewController?.previewControllerDelegate = self
    }
    self.present(previewViewController!, animated: true, completion: nil)
    })
    return
}



https://developer.apple.com/documentation/replaykit/rpscreenrecorder/1620990-stoprecording


来源:https://stackoverflow.com/questions/53880491/how-to-disable-screen-recording-in-ios-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!