![](/img/trans.png)
[英]How to disable only screen recording (not screenshot) in android and ios with Flutter?
[英]How to restrict screen recording in iOS devices in Flutter?
我正在 Flutter 中開發一個應用程序,我需要限制在 iOS 設備中的屏幕錄制。 我現在所做的是檢查 AppDelegate 中的 UIScreen.main.isCaptured 標志,並使用我的 dart 文件中的計時器經常檢查它。
有沒有更好的方法通過使用來自蘋果的 captureDidChangeNotification 來做到這一點,這樣我就不必運行計時器並且在屏幕錄制狀態發生變化時通知 dart 文件?
您添加capturedDidChangeNotification
在觀察者通知中心,推動結果FlutterEventChannel。 然后在 Dart 端你設置EventChannel ,它有receiveBroadcastStream
方法,它返回一個你可以聽的流。 確保在 iOS 部分和 Flutter 上處理關閉 Streams。
您可以通過收聽電池充電來查看這些官方示例,這幾乎相同(NotificationCenter + Streams):
https://github.com/flutter/flutter/blob/master/examples/platform_channel_swift/ios/Runner/AppDelegate.swift https://github.com/flutter/flutter/blob/master/examples/platform_channel_swift/lib/main 。鏢
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.