ios - 再次请求访问相机时如何恢复默认状态(状态==。未确定)
问题描述
我正在开发一个具有录音功能的应用程序。
我知道当用户第一次被要求访问请求时,授权状态是不确定的。一旦用户被要求访问相机(这是用户选择是否授权或拒绝的时候),授权状态将无法恢复到默认状态(状态 == .notDetermined)。
为了测试,有没有办法获得默认状态(status == .notDetermined)?
switch AVCaptureDevice.authorizationStatus(for: .video) {
case .authorized: // The user has previously granted access to the camera.
self.setupCaptureSession()
case .notDetermined:
// The user has not yet been asked for camera access.
// Once the user has been asked for camera access, this will never be executed again.
AVCaptureDevice.requestAccess(for: .video) { granted in
if granted {
self.setupCaptureSession()
}
}
case .denied: // The user has previously denied access.
return
case .restricted: // The user can't grant access due to restrictions.
return
}
解决方案
卸载已经存在的应用程序并尝试在一天后重新安装新版本以.notDetermined
获得AVCaptureDevice.authorizationStatus
. 您无法以编程方式重置权限。您也可以通过重置设备来重置权限,这似乎有点苛刻。总之,有两种方法可以做到这一点:
- 重置操作系统
- 卸载应用程序并等待一天
推荐阅读
- excel - How to fill in blank cells in this column, when the cells have to be populated with different values from this same column?
- php - Update taxonomy field from ACF field when saving post
- android - How show hidden folder starting with a dot having a video file from android internal storage programatically?
- javascript - typescript/node/sequelize - How to add variables when getting dynamic value
- settings - How to correctly edit scalability settings/groups in Unreal Engine 4? To "overwrite" the default one's
- python - 将 python 方法转换为 djagno 数据库方法是否可行?
- java - java - 如何在java json中转义双引号?
- r - 将来自多个参数的值添加到最终总和
- c - 如何在 Kotlin/Native 中从 C 导入生成的 Kotlin 类?
- python - Pandas 散点图上不显示 X 轴标签和次要刻度标签