How to detect screenshots on iOS (like SnapChat)
来源:互联网 发布:手机外卖软件咋接单 编辑:程序博客网 时间:2024/05/29 18:43
http://blog.chpwn.com/post/38491252231
A number of Stack Overflow questions were having issues with this, so I figured I’d explain. From reverse engineering, this is the exact method used by SnapChat, but it’s also pretty much what I’d have done myself.
The process is pretty simple, and relies on a quirk of iOS: taking a screenshot cancels all touches on the screen. Because of that, anything that you want to protect will require you to have the user to touch the screen to see. If that works for your purposes, the general solution is to simply intercept the touch cancellation, and quickly remove any sensitive information from the screen. If you’re also implementing a screenshot counter, as with SnapChat, you will also need to take into account the other cases when a touch might be cancelled: from a system gesture (Notification Center or the iPad’s multitasking gestures), or by activating other pieces of system UI (the power down menu, or the multitasking switcher).
On a technical level, the two basic pieces are UILongPressGestureRecognizer
(or -touchesCancelled:withEvent:
, if you want) and UIApplicationDelegate
. In your long press handler, you should hide your sensitive information when the gesture recognizer’s state
is UIGestureRecognizerStateCancelled
, and if you want to track the number of screenshots, increment a counter. Then, in the UIApplicationDelegate
, decrement that counter when you receive the -applicationWillEnterBackground:
or -applicationDidResignActive:
notification to account for the other possibilities for a cancelled touch. You might also need to handle other situations where a touch could be cancelled, if other parts of your app might cause that to happen.
- How to detect screenshots on iOS (like SnapChat)
- How to take screenshots on your Samsung Galaxy Tab 10.1
- How to make DirectFB screenshots
- How to Make Great App Store Screenshots
- [WP7] How to press the mouse on a control, and detect MouseLeftButtonUp on another
- how to solve vim settings like highlight in iOS
- How to Customize UITabBar on iOS 5
- How to Parse HTML on iOS
- How to Customize UITabBar on iOS 5
- How to Customize UITabBar on iOS 5
- How to Customize UITabBar on iOS 5
- How to debug Javascript errors on iOS
- How to run cpp-tests on iOS
- How to share on Facebook obout iOS?
- How to Parse HTML on iOS
- how to fix some resource like video not show on iphone 6 but show on simulator
- How to Detect a Dialup Connection?
- How to detect the explorer in js
- CSharp tar类型文件压缩与解压
- PHP 重建数组函数 array_values
- html5 笔记4 地理定位(Geolocation)
- JAVADBF操作
- wordpress 使用固定链接
- How to detect screenshots on iOS (like SnapChat)
- 超级程序员神话
- Registering an Image Using Normalized Cross-Correlation
- 正则学习
- 符号链接
- uninstall Launchy with WindowsUninstaller.Org Removal Tips
- SQLSERVER的数据页
- 招聘题8.29
- java.lang.UnsupportedOperationException at java.util.AbstractList