ios录制屏幕_如何使您的ios应用免受屏幕截图和录制的影响

ios录制屏幕

防止在iOS App中捕获和录制屏幕(Preventing Screen Capturing and Recording in iOS App)

Thanks to the mobile era we have mobile apps for everything these days. Every business from a barbers shop to huge retailers has apps so that they can be closer to their customers. On one hand, we really leverage this convenience but on the other hand, there are risks of exposing a lot of confidential information while using these apps. And it becomes very vital when dealing with payments and other sensitive information. As a developer of these apps, it is our responsibility to put checks to make sure privacy and security are not compromised. One of the ways is to detect/prevent screenshot and screen recording action and taken an action or inform the user to take appropriate action.

牛逼汉克斯移动时代,我们拥有的一切,这些天移动应用。 从理发店到大型零售商,每一项业务都有应用程序,以便它们可以更接近客户。 一方面,我们确实利用了这种便利,但另一方面,在使用这些应用程序时,存在暴露大量机密信息的风险。 在处理付款和其他敏感信息时,它变得至关重要。 作为这些应用程序的开发人员,我们有责任进行检查,以确保不损害隐私和安全性。 一种方法是检测/防止屏幕截图和屏幕记录动作以及已采取的动作或通知用户采取适当的动作。

用例 (Use Cases)

Here are some use cases where screen capture and screen recording can expose sensitive information:

在以下一些用例中,屏幕捕获和屏幕记录可能会泄露敏感信息:

1.可以记录登录信息 (1. Login information can be recorded)

Any app that requires a login to get access to sensitive information. We need to make sure that only the intended person can log in. If screen recording or screen capture is allowed on the login it can expose confidential information.

需要登录才能访问敏感信息的任何应用程序。 我们需要确保只有预定的人才能登录。如果登录时允许屏幕录像或屏幕截图,则它可能会泄露机密信息。

2.记录流内容 (2. Recording of Streaming Content)

Let’s take an example of a content streaming app, for example, Netflix, which I think everyone is aware of. We pay a monthly subscription to stream content. If screen recording was allowed, one can record with the device’s recording option and watch the content later without even having a membership.

让我们以内容流应用程序为例,例如Netflix,我认为每个人都知道。 我们按月订阅以流式传输内容。 如果允许进行屏幕录制,则可以使用设备的录制选项进行录制,并且以后甚至无需拥有成员身份即可观看内容。

3.付款信息 (3. Payment Information)

Any retail or banking app deals with payment/transactions. From a security point of view, we need to be watchful of any information being captured from the app to protect the user’s account. If we aren’t careful it will lead to a major leak in from application and secured transaction details will be compromised.

任何零售或银行应用程序都处理付款/交易。 从安全角度来看,我们需要注意从应用程序捕获的任何信息,以保护用户的帐户。 如果我们不小心,将会导致应用程序的重大泄漏,安全交易细节将受到损害。

这是实现它的方法 (Here is how you implement it)

1.如何防止屏幕捕获(1. How to Prevent Screen Capture)

As a developer, we can prevent/track screenshot very easily by listening to notification userDidTakeScreenshotNotification available in iOS 11 and above.Let’s see the code in action

作为开发人员,我们可以通过侦听iOS 11及更高版本中提供的通知userDidTakeScreenshotNotification来轻松防止/跟踪屏幕截图。

class ViewController: UIViewController {override func viewDidLoad() {super.viewDidLoad()// Do any additional setup after loading the view.NotificationCenter.default.addObserver(self, selector: #selector(didTakeScreenshot(notification:)), name: UIApplication.userDidTakeScreenshotNotification, object: nil)}@objc func didTakeScreenshot(notification:Notification) -> Void {print("Screen Shot Taken")}}

In the code above we are adding ourselves as an observer to notification userDidTakeScreenshotNotification and catching with function didTakeScreenShot which will get triggered anytime a user tries to take a screenshot. At this point in time as a developer, we have the opportunity to handle in a way we want for our app. For eg. show a warning message and then kill the app after informing the user. Here is a gif that captures it.

在上面的代码中,我们将自己作为观察者添加到通知userDidTakeScreenshotNotification中,并捕获了didTakeScreenShot函数,该函数在用户每次尝试截屏时都会被触发。 目前,作为开发人员,我们有机会以我们想要的方式处理我们的应用程序。 例如。 显示警告消息,然后在通知用户后终止该应用程序。 这是捕获它的gif。

How to prevent screen capturing in iOS App?

2.如何防止屏幕记录 (2. How to Prevent Screen Recording)

To check if a screen is getting captured/recording all we have to do is check for isCaptured property on UIScreen. Let’s look at the code sample below

要检查屏幕是否正在捕获/记录,我们要做的就是检查UIScreen上的isCaptured属性。 让我们看看下面的代码示例

func isRecording() ->Bool {for screen in UIScreen.screens {if (screen.isCaptured) {print("screen is recorded")return true}}return false}

We can decide to check for recording by calling the method isRecording. We can call this method depending on our needs. We can either call it on different states of our view life cycle or having a timer to check for this. Here is a demo that shows screen recording detection.

我们可以通过调用isRecording方法来决定是否检查记录 我们可以根据需要调用此方法。 我们可以在视图生命周期的不同状态下调用它,也可以使用计时器进行检查。 这是显示屏幕录制检测的演示。

How to prevent screen recording in iOS App?

结论 (Conclusion)

Detecting screenshot capturing and recording can be very useful from a security and privacy point of view in the app. This adds trust and reliability in the app that potentially millions of people can use. I would love to hear about your use cases and experiences with screen capturing measures that you might have used.

从应用程序的安全性和隐私性的角度来看,检测屏幕快照的捕获和记录可能非常有用。 这增加了潜在的数百万人可以使用的应用程序的信任度和可靠性。 我很想听听您的用例以及您可能使用过的截屏方法的经验。

寻找更多安全最佳实践? (Looking for more security best practices?)

Originally published at https://www.shashankthakur.dev.

最初发布在https://www.shashankthakur.dev

翻译自: https://medium.com/swlh/how-to-make-your-ios-app-secure-from-screen-shot-and-recording-82b6aea26b33

ios录制屏幕

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值