Open vptcnt opened 1 year ago
You shouldnt be using this to begin with, this is not the correct way to detect screenshots, this may break your UI, if not now, then in further releases of iOS, but for the sake of information, you can create a swift file which will import the ScreenProtectorKit swift file and expose functions to objc.
import UIKit import ScreenProtectorKit
@objc public class ScreenProtectorBridge: NSObject {
private var protectorKit: ScreenProtectorKit?
@objc public static let shared = ScreenProtectorBridge()
private override init() {
super.init()
}
@objc public func setup(window: UIWindow?) {
protectorKit = ScreenProtectorKit(window: window)
}
@objc public func configurePreventionScreenshot() {
protectorKit?.configurePreventionScreenshot()
}
@objc public func enablePreventScreenshot() {
protectorKit?.enabledPreventScreenshot()
}
@objc public func disablePreventScreenshot() {
protectorKit?.disablePreventScreenshot()
}
@objc public func enableBlurScreen(style: UIBlurEffect.Style = .light) {
protectorKit?.enabledBlurScreen(style: style)
}
@objc public func disableBlurScreen() {
protectorKit?.disableBlurScreen()
}
@objc public func enableColorScreen(hexColor: String) {
protectorKit?.enabledColorScreen(hexColor: hexColor)
}
@objc public func disableColorScreen() {
protectorKit?.disableColorScreen()
}
@objc public func enableImageScreen(named: String) {
protectorKit?.enabledImageScreen(named: named)
}
@objc public func disableImageScreen() {
protectorKit?.disableImageScreen()
}
@objc public func removeAllObserver() {
protectorKit?.removeAllObserver()
}
@objc public func observeScreenshot(callback: @escaping () -> Void) {
protectorKit?.screenshotObserver(using: callback)
}
@available(iOS 11.0, *)
@objc public func observeScreenRecord(callback: @escaping (Bool) -> Void) {
protectorKit?.screenRecordObserver(using: callback)
}
@available(iOS 11.0, *)
@objc public func isScreenRecording() -> Bool {
return protectorKit?.screenIsRecording() ?? false
}
}
then in objective c controller use
and use like this [[ScreenProtectorBridge shared] setupWithWindow:self.window]; [[ScreenProtectorBridge shared] configurePreventionScreenshot]; [[ScreenProtectorBridge shared] enablePreventScreenshot];
Hello,
Do you know how to implement your library in an Ios written in Obj-C ?
Thanks for your help