简体   繁体   English

检测iPhone的电源关闭事件以防止在iOS中截屏

[英]Detect iPhone power button down event to prevent screen shot in iOS

I'm working on the feature to prevent ScreenShot taken from my application. 我正在使用该功能以防止ScreenShot从我的应用程序中获取。 We can achieve this by Configuration Profile which available on Enterprise Developer Account. 我们可以通过Enterprise Developer Account上的Configuration Profile来实现。 The thing is i want to do it in Developer Account. 事情是我想在开发人员帐户中执行此操作。 So i'm tried below techniques 所以我尝试了以下技术

  1. Observing the UIApplicationUserDidTakeScreenshotNotification notification. 观察UIApplicationUserDidTakeScreenshotNotification通知。 But it was triggered after the screen shot taken. 但它是在截屏后触发的。
  2. Tried to use a touchesCancelled: method. 尝试使用touchesCancelled:方法。 From iOS7 onwards touchesCancelled: is not called during screenshot taken. 从iOS7开始,在截屏期间不会调用touchesCancelled:。
  3. When i'm looking on device log, the below outputs was logged. 当我查看设备日志时,记录了以下输出。

    Mar 14 13:05:58 iPod backboardd[58] : Lock usagePage:0xc usage:0x30 downEvent:1 down Mar 14 13:05:58 iPod SpringBoard[53] : canceling volume button presses 3月14日13:05:58 iPod背板[58]:锁定用法页面:0xc使用率:0x30向下事件:1向下3月14日13:05:58 iPod SpringBoard [53]:取消按下音量按钮
    Mar 14 13:05:59 iPod backboardd[58] : Home usagePage:0xc usage:0x40 downEvent:0 up 3月14日13:05:59 iPod背板[58]:家庭使用率页面:0xc使用率:0x40下事件:0上
    Mar 14 13:05:59 iPod SpringBoard[53] : Take screenshot: 3 3月14日13:05:59 iPod SpringBoard [53]:截图:3
    Mar 14 13:05:59 iPod ScreenShot[4689] : Name :::_UIWindowSystemGestureStateChangedNotification Mar 14 13:05:59 iPod backboardd[58] : Lock usagePage:0xc usage:0x30 downEvent:0 up 3月14日13:05:59 iPod ScreenShot [4689]:名称::: __ UIWindowSystemGestureStateChangedNotification 3月14日13:05:59 iPod背板[58]:锁定用法页面:0xc用法:0x30 down事件:0向上
    Mar 14 13:05:59 iPod backboardd[58] : Home usagePage:0xc usage:0x40 downEvent:0 phase:0x4 timeout 3月14日13:05:59 iPod背板[58]:家庭使用情况页面:0xc使用情况:0x40下事件:0阶段:0x4超时
    Mar 14 13:05:59 iPod SpringBoard(FrontBoard)[53] : [FBSystemService][0x7bd4] Received request to open "com.apple.ScreenshotServicesService" from SpringBoard:53. 3月14日13:05:59 iPod SpringBoard(FrontBoard)[53]:[FBSystemService] [0x7bd4]从SpringBoard:53收到了打开“ com.apple.ScreenshotServicesService”的请求。
    Mar 14 13:05:59 iPod SpringBoard[53] : sending screenshot action to scene: 3月14日13:05:59 iPod SpringBoard [53]:向场景发送屏幕截图动作:
    Mar 14 13:05:59 iPod SpringBoard(FrontBoard)[53] : [FBSystemService][0x5ca0] Received request to open "com.apple.ScreenshotServicesService" from SpringBoard:53. 3月14日13:05:59 iPod SpringBoard(FrontBoard)[53]:[FBSystemService] [0x5ca0]从SpringBoard:53收到了打开“ com.apple.ScreenshotServicesService”的请求。
    Mar 14 13:05:59 iPod SpringBoard(FrontBoard)[53] : [FBSystemService] Trusting entitled client . 3月14日13:05:59 iPod SpringBoard(FrontBoard)[53]:[FBSystemService]受信任的客户端。

3.1 Tried to trace the device logs using ASL . 3.1试图使用ASL跟踪设备日志。 This is also deprecated. 也已弃用。

3.2 Tried to access the system processes using sysctl() . 3.2尝试使用sysctl()访问系统进程。 This is also deprecated 也已弃用

3.3 Tried to access the iPhones Private Frameworks to Swizzle the methods on it. 3.3试图访问iPhone专用框架以混淆其上的方法。 But no luck i can't find correct method to swizzle. 但是,运气不好,我找不到正确的方法。 I know this is not recommended just i'd tried. 我知道这不推荐,只是我尝试过。

Is there any solutions to obtain this case before screen shot is taken, so that i'll change the Application UI. 是否有任何解决方案可以在截屏之前获得这种情况,以便我更改应用程序UI。

Thanks., 谢谢。,

看一看https://screenshieldkit.com ,我认为它们满足了您的需求,并且通过使用UIApplicationUserDidTakeScreenshotNotification,您还可以通知其他用户已使用screenShot

You can't. 你不能

The only publicly available API is to know that a screenshot is already taken , but it doesn't allow to prevent it (it informs after the screenshot was made). 唯一可公开使用的API是知道已经使用了屏幕截图 ,但不允许这样做(它会在创建屏幕截图通知)。

Yes, on older iOS versions it used to be possible to surpass this restriction, but on newer iOS versions this is not possible yet (at least not without jailbreaking). 是的,在较旧的iOS版本上,曾经有可能超越此限制,但是在较新的iOS版本上,这是不可能的(至少没有越狱的情况)。

Anyway, that's a native option given by iOS, so blocking it would lead to app rejection in the App Store anyway. 无论如何,这是iOS提供的本机选项,因此阻止它无论如何都会导致App Store中的应用程序被拒绝。 You should implement other techniques like Instagram Stories and stuff like that do: they inform the publisher of the content that a screenshot was taken. 您应该实施其他技术(例如Instagram故事)以及类似的技术:它们将内容告知屏幕快照的发布者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM