简体   繁体   English

如何在 Flutter 中限制 iOS 设备的屏幕录制?

[英]How to restrict screen recording in iOS devices in Flutter?

I am developing an app in Flutter, which I need to restrict screen recording in iOS devices.我正在 Flutter 中开发一个应用程序,我需要限制在 iOS 设备中的屏幕录制。 What I have done now is checking for the UIScreen.main.isCaptured flag in the AppDelegate and checking it frequently using a timer in my dart file.我现在所做的是检查 AppDelegate 中的 UIScreen.main.isCaptured 标志,并使用我的 dart 文件中的计时器经常检查它。

Is there a better way to do this by making use of capturedDidChangeNotification from apple, so that I don't have to run a timer and the dart file get notified when the screen recording status changes?有没有更好的方法通过使用来自苹果的 captureDidChangeNotification 来做到这一点,这样我就不必运行计时器并且在屏幕录制状态发生变化时通知 dart 文件?

You add capturedDidChangeNotification observer on NotificationCenter and push the result to FlutterEventChannel.您添加capturedDidChangeNotification在观察者通知中心,推动结果FlutterEventChannel。 Then on Dart side you setup EventChannel , which has receiveBroadcastStream method that returns a Stream than you can listen to.然后在 Dart 端你设置EventChannel ,它有receiveBroadcastStream方法,它返回一个你可以听的流。 To be sure to handle closing Streams both on iOS part and Flutter.确保在 iOS 部分和 Flutter 上处理关闭 Streams。

You can checkout these official example with listening to battery charging, which is almost the same (NotificationCenter + 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.dart 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.

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