ScreenCaptureDetector is heler tool that can detect if the application is being capture via mirror screen or recorded in addition to screenshot alert
- adds an overlay to your app when it is capture or mirrored
To run the example project, clone the repo, and run pod install
from the Example directory first.
Swift 5
CocoaPods
ScreenCaptureDetector is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'ScreenCaptureDetector'
Simply import ScreenCaptureDetector in AppDelegate: import ScreenCaptureDetector
Add the following to AppDelegate's didFinishLaunchingWithOptions:
///How to use using default instance
let monitor = ScreenCaptureRecordingDetector.createDafaultInstnace()
monitor.startMonitor()
Or "Recommended"
1- conform protocol ScreenCaptureDelegate that has 3 optional func :
func didStartCapture()
func didEndCapture()
func didTakeScreenshot()
2- passing the conformed class to the init method of ScreenCaptureRecordingDetector
3- calling method startMonitor() to start
4- calling method endMonitor() to stop
Or
///How to use using NotificationCenter
let monitor = ScreenCaptureRecordingDetector()
monitor.delegate = nil
monitor.startMonitor()
NotificationCenter.default.addObserver(self, selector: #selector(showScreen), name: .screenCapturingStarted, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(dimissScreen), name: .screenCapturingEnded, object: nil)
Or
///How to use using Custom view
let appDelegate = UIApplication.shared.delegate as? AppDelegate
let overWindow = appDelegate?.window
let customView = UIView.init(frame: overWindow?.bounds ?? CGRect.init(x: 0, y: 0, width: 200, height: 200))
customView.backgroundColor = .yellow
let screenCaptureDelegate = ScreenCaptureDelegateDefaultImpl(suspendView: customView, drawOver: overWindow)
let monitor = ScreenCaptureRecordingDetector(delegate: screenCaptureDelegate)
monitor.startMonitor()
Xcode Version 11.3.1
Swift 5.0
All your feedback and help to improve this project is very welcome. Please create issues for your bugs, ideas and enhancement requests, or better yet, contribute directly by creating a PR. 😎
When reporting an issue, please add a detailed instruction, and if possible a code snippet or test that can be used as a reproducer of your problem. 💥
When creating a pull request, please adhere to the current coding style where possible, and create tests with your code so it keeps providing an awesome test coverage level 💪
amrangry,
WebSite: https://amrangry.github.io/
Email : [email protected]
ScreenCaptureDetector is available under the MIT license. See the LICENSE file for more info.