You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter iOS应用防截屏功能遭App Store拒审,求解决方案

解决App Store拒审:防截屏功能重复系统界面问题

问题根源

你当前使用的UITextField安全输入框hack方案,在触发截屏时可能弹出了与iOS系统截屏界面高度相似的自定义界面,违反了苹果"避免重复系统原生UI"的审核准则。

修正方案

1. 移除重复系统UI的自定义触发界面

完全删除任何模仿iOS系统截屏弹窗、样式的自定义界面,苹果允许应用限制截屏/录屏,但禁止复制系统原生交互或视觉设计。

2. 改用合规的防截屏实现

放弃原有的makeSecure() hack方案,使用iOS官方提供的屏幕捕获监听API,实现无系统UI模仿的内容遮挡或提示:

原生iOS修正代码(Swift)

替换原UIWindow扩展,改用系统通知监听屏幕捕获状态:

// 在你的FlutterViewController或AppDelegate中添加监听
override func viewDidLoad() {
    super.viewDidLoad()
    // 监听屏幕捕获状态变化(截屏、录屏都会触发)
    NotificationCenter.default.addObserver(
        self,
        selector: #selector(screenCaptureStateChanged),
        name: UIScreen.capturedDidChangeNotification,
        object: nil
    )
}

@objc private func screenCaptureStateChanged() {
    let isBeingCaptured = UIScreen.main.isCaptured
    if isBeingCaptured {
        // 添加自定义遮挡层(样式完全区别于系统截屏界面)
        let overlay = UIView(frame: view.bounds)
        overlay.backgroundColor = UIColor.black.withAlphaComponent(0.9)
        overlay.tag = 1001 // 标记用于后续移除
        
        let tipLabel = UILabel()
        tipLabel.text = "当前页面禁止截屏录屏"
        tipLabel.textColor = .white
        tipLabel.font = UIFont.systemFont(ofSize: 16)
        tipLabel.textAlignment = .center
        tipLabel.translatesAutoresizingMaskIntoConstraints = false
        
        overlay.addSubview(tipLabel)
        NSLayoutConstraint.activate([
            tipLabel.centerXAnchor.constraint(equalTo: overlay.centerXAnchor),
            tipLabel.centerYAnchor.constraint(equalTo: overlay.centerYAnchor)
        ])
        
        view.addSubview(overlay)
    } else {
        // 移除遮挡层
        view.viewWithTag(1001)?.removeFromSuperview()
    }
}

// 记得移除监听(如在deinit中)
deinit {
    NotificationCenter.default.removeObserver(self)
}

3. Flutter端适配

通过MethodChannel将原生的屏幕捕获监听逻辑暴露给Flutter层,或者直接在原生层完成遮挡逻辑,避免Flutter端弹出类似系统的提示界面。

审核注意事项

  • 遮挡层的视觉设计必须完全区别于iOS系统截屏界面,避免使用系统默认的弹窗样式、按钮布局。
  • 仅在必要页面启用防截屏功能,不要全局强制开启(除非有合规的业务需求,如敏感信息展示)。

内容的提问来源于stack exchange,提问作者Deniz Durmaz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 20:31:02