问题:
在支付等敏感页面,可以截屏,存在安全风险。
修改
截屏既然是禁止的,那么就在基类中加禁止截屏功能。这样几乎所有页面都不能截屏了。
// 防止截屏
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
如果截屏,系统会通过Toast提示:此应用或您所在单位不允许截屏
参考文章
关于android app防翻录防截屏功能的一个小问题
android -防截屏
iOS防截屏
iOS
没有防截屏功能,相应的有监控截屏功能。如果用户截屏了,系统会发送UIApplicationUserDidTakeScreenshotNotification
。所以,只要监控这个消息,然后给出提示就可以了。
-
ViewDidLoad
中
// 监控截屏
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(monitorScreenshot:) name:UIApplicationUserDidTakeScreenshotNotification object:nil];
-
dealloc
中
- (void)dealloc {
NSLog(@"%@退出了。",NSStringFromClass([self class]));
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationUserDidTakeScreenshotNotification object:nil];
}
- 提示用户,模拟
Android
的Toast
// 监控截屏
- (void)monitorScreenshot:(NSNotification *)notification {
[KJTHud toast:@"检测到截屏,操作需谨慎。"];
}