ReplayKit 初始警报选择的委托方法是什么?

2024-04-19

当用户第一次决定使用 ReplayKit 时,会出现一条警报。它给出了 3 个选择:

-Record Screen and Microphone
-Record Screen Only
-Don’t Allow

有哪些委托方法可以帮助我找出用户选择的选项?


没有任何委托方法来确定用户选择哪个选项。你必须使用完成处理程序 https://developer.apple.com/documentation/replaykit/rpscreenrecorder/2867291-startcapture and .is麦克风已启用 https://developer.apple.com/documentation/replaykit/rpscreenrecorder/1620987-ismicrophoneenabled以确定所选择的选项。

一旦选择了一个选项completionHandler叫做:

  1. 如果用户选择Don't Allow那么error代码将运行

  2. 如果用户选择Record Screen & Microphone then .isMicrophoneEnabled将被设置为true

  3. 如果用户选择Record Screen Only then .isMicrophoneEnabled将被设置为false

在 - 的里面completionHandler您可以检查他们的选择,然后从那时起做您需要做的任何事情。阅读 2 条评论completionHandler下面的部分代码。

let recorder = RPScreenRecorder.shared()

recorder.startCapture(handler: { [weak self](buffer, bufferType, err) in

    // ...

}, completionHandler: { (error) in

    // 1. If the user chooses "Dont'Allow", the error message will print "The user declined application recording". Outside of that if an actual error occurs something else will print
    if let error = error {
        print(error.localizedDescription)
        print("The user choose Don't Allow")
        return
    }

    // 2. Check the other 2 options
    if self.recorder.isMicrophoneEnabled {

        print("The user choose Record Screen & Microphone")

    } else {

        print("The user choose Record Screen Only")
    }
})

安全的方法可以让您知道如何应对每个错误代码 https://developer.apple.com/documentation/replaykit/rprecordingerrorcode是对错误代码使用 switch 语句:

}, completionHandler: { (error) in

    if let error = error as NSError? {

        let rpRecordingErrorCode = RPRecordingErrorCode(rawValue: error.code)
        self.errorCodeResponse(rpRecordingErrorCode)
    }
})

func errorCodeResponse(_ error: RPRecordingErrorCode?) {

    guard let error = error else { return }

    switch error {

    case .unknown:
        print("Error cause unknown")
    case .userDeclined:
        print("User declined recording request.")
    case .disabled:
        print("Recording disabled via parental controls.")
    case .failedToStart:
        print("Recording failed to start.")
    case .failed:
        print("Recording error occurred.")
    case .insufficientStorage:
        print("Not enough storage available on the device.")
    case .interrupted:
        print("Recording interrupted by another app.")
    case .contentResize:
        print("Recording interrupted by multitasking and content resizing.")
    case .broadcastInvalidSession:
        print("Attempted to start a broadcast without a prior session.")
    case .systemDormancy:
        print("Recording forced to end by the user pressing the power button.")
    case .entitlements:
        print("Recording failed due to missing entitlements.")
    case .activePhoneCall:
        print("Recording unable to record due to active phone call.")

    default: break
    }
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

ReplayKit 初始警报选择的委托方法是什么? 的相关文章

随机推荐

  • 响应式表格,智能方式

    我有一个包含数据的表 表格数据 它看起来像这样 See 这把小提琴 http jsfiddle net MrLister c54RN 现在我想要的是 当它显示在较窄的屏幕上时 表格看起来像这样 这样你就不会得到水平滚动条并且它保持相同的视觉
  • 尝试使用锐利的 Node.js 调整流图像的大小

    我正在尝试使用锐利功能调整从用户到服务器的输入流图像的宽度和高度 但图像没有任何反应 它保持原来的大小 我应该如何使用锐化功能 以便我可以使图像变小或变大 请帮我 这就是我的代码的样子 use strict const builder re
  • 比较堆栈中的两个值? [复制]

    这个问题在这里已经有答案了 我卡住了 在我的汇编代码中 我想比较两个值 堆 x86 语法 AT T cmpl 4 ebp 4 ebp 错误 cmp 的内存引用太多 我认为不可能根据乘数和 ebp 来比较两个值 有什么建议 您可以使用 CMP
  • 如何将空白复选框作为 false 传递给参数

    我有一个更新用户表单的表单 其中几个元素是复选框 我希望 true 传递给参数 如果选中 这是工作 false 传递给参数 如果未选中 不工作 未经检查的项目甚至没有发送到参数 如何使未检查的项目作为错误通过 Form h4 Please
  • Junit 异常测试用例 [关闭]

    Closed 这个问题需要细节或清晰度 help closed questions 目前不接受答案 public class TipException extends Exception private final Object mSour
  • Python ARIMA模型,预测值发生偏移

    我是 Python ARIMA 实现的新手 我有几个月 15 分钟一次的数据 我尝试遵循 Box Jenkins 方法来拟合时间序列模型 我在最后遇到了一个问题 这ACF PACF图 https i stack imgur com weNJ
  • Haskell 中自动函数约束推导的类型约束

    出于教育目的 我在 Haskell 中摆弄树木 我有Tree a像这样定义的类型 data Tree a EmptyTree Node a Tree a Tree a 以及许多共享基本约束的函数 Ord a 所以他们有这样的类型 treeI
  • 无法点击 iframe 内的按钮

    设想 Launch http www indiabookstore net http www indiabookstore net 点击FB 类似按钮它位于 iframe 内 向下滚动即可看到 Issue 我可以切换到 iframe 但无法
  • Android 上的图像处理 - 我可以使用哪些库?

    我专门需要它来处理图像失真 滤镜 模糊等 也欢迎 你知道一些我可以使用的具有适当许可证的库 还有 Apache MIT LGPL 吗 价格合理的专有图书馆 也向他们开放 也可以用C语言 提前致谢 达内尔 您可能想查看OpenCV http
  • 我的 Web API 序列化出现错误

    我有一个带有多个返回不同结果的控制器的 WebApi 例如 一个控制器返回了IEnumerable
  • ImportError:LinuxMint17.3 中“没有名为plotly.plotly 的模块”

    每当我尝试编译以下代码以获得折线图时 都会显示一些错误 但我不知道如何解决它 这是我的code https plot ly python line charts import plotly plotly as py import plotl
  • Apple 推送通知 (APN) 不一致?

    通过 APN 使用 Apple 的推送通知时 我们遇到了一个令人困惑的问题 我们有以下场景 我猜是相当标准的 当我们的应用程序 我们在这里称之为 MyApp 首次安装并启动时 我们会请求用户授予通过 MyApp 向他发送推送通知的权限 在此
  • 是否有 java.util.Properties 类的 C# 类似物

    Java 有一个 Properties 类 非常适合保存基本配置信息 例如您希望从一个会话持续到下一个会话的 GUI 设置 我记得它保存和检索键值对 并且使用起来非常简单 我一直在 C 中寻找类似的东西 但没有成功 我错过了吗 如果没有 除
  • 防止 NE 用于 lm 回归

    我有一个包含未来收益的向量 Y 和一个包含当前收益的向量 X 最后一个 Y 元素是 NA 因为最后一个电流返回也是可用系列的最后一个 X 0 1 0 3 0 2 0 5 Y 0 3 0 2 0 5 NA Other 5500 222 523
  • Osmnx python graph_to_gdfs 有时会在名称列中返回一个列表,是什么原因造成的?

    我正在使用 OSmnx 创建一些漂亮的地图 其中我根据街道名称为街道着色 灵感来自 puntofisso 例如 如果是街道 则需要是红色 车道是绿色等 我注意到有时边的名称不是字符串 而是列表 到目前为止我已经解决了这个问题 但是有一个论点
  • @Cache注解使用错误

    我添加了以下注释以启用对我的 EJB3 实体之一的缓存 以使用 ehCache 测试缓存 其中我使用 Hibernate 作为持久性提供程序 import org hibernate annotations Cache import org
  • 模块 PIL 没有属性“重新采样”

    我之前运行过相同的代码 带有我需要的包 并且它有效 不确定现在发生了什么 这显示错误 AttributeError module PIL Image has no attribute Resampling 可能这是一个小问题 但我无法弄清楚
  • 如何按顺序检查一个列表是否是另一个列表的子序列[重复]

    这个问题在这里已经有答案了 我有一个清单input 1 2 4 3 5 7 5 3 8 3 8 5 8 5 9 5 7 5 7 4 9 7 5 7 4 7 4 7 8 9 7 5 7 5 4 9 3 4 8 4 8 5 3 5 4 7 3
  • datatype.text 验证什么?

    我有一个生产应用程序正在接受我们的安全扫描CWE 100 https cwe mitre org data definitions 100 html 我知道这是一个已弃用的项目 但它仍然显示在我的报告中 目前我只看到要采取两个行动 处理好每
  • ReplayKit 初始警报选择的委托方法是什么?

    当用户第一次决定使用 ReplayKit 时 会出现一条警报 它给出了 3 个选择 Record Screen and Microphone Record Screen Only Don t Allow 有哪些委托方法可以帮助我找出用户选择