简体   繁体   English

检测我的iOS应用中的任何APP上截取的屏幕截图

[英]Detect screenshots taken ON ANY APP within my iOS app

Is it possible to detect when the user takes a screenshot in any app while my app is in the background ? 当我的应用程序在后台时,是否可以检测用户何时在任何应用程序中截屏? And how would I do that ? 那我该怎么办?

If not, can I background check regularly for screenshots (not pictures from the camera) in the photo library ? 如果没有,我可以定期检查照片库中的截图(不是相机中的照片)吗? Like every minute or hour ? 像每分钟或每小时?

One way to get your app to detect Screenshots is: 让您的应用检测屏幕截图的一种方法是:

  1. Register with the Photo Library's PHPhotoLibraryChangeObserver 注册照片库的PHPhotoLibraryChangeObserver

  2. When your app receives a notification that a photo has been added, check its PHAssetMediaSubtype 当您的应用收到添加了照片的通知时,请检查其PHAssetMediaSubtype

  3. If the Subtype is PHAssetMediaSubtypePhotoScreenshot, you know a new Screenshot has been taken. 如果子类型是PHAssetMediaSubtypePhotoScreenshot,您知道已经拍摄了新的屏幕截图。

The PHPhotoLibraryChangeObserver protocol notifies you of changes that occur in the Photos library, regardless of whether those changes are made by your app, by a user in the Photos app, or by another app that uses the Photos framework. PHPhotoLibraryChangeObserver协议会通知您照片库中发生的更改,无论这些更改是由您的应用程序,照片应用程序中的用户还是使用照片框架的其他应用程序进行的。

https://developer.apple.com/reference/photos/phphotolibrarychangeobserver https://developer.apple.com/reference/photos/phphotolibrarychangeobserver

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

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