QR Code Login Flow (#2767)
Co-authored-by: Hugh Nimmo-Smith <hughns@users.noreply.github.com> Co-authored-by: Hugh Nimmo-Smith <hughns@element.io>
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import AVFoundation
|
||||
import UIKit
|
||||
|
||||
class AppMediator: AppMediatorProtocol {
|
||||
@@ -64,4 +65,22 @@ class AppMediator: AppMediatorProtocol {
|
||||
func setIdleTimerDisabled(_ disabled: Bool) {
|
||||
application.isIdleTimerDisabled = disabled
|
||||
}
|
||||
|
||||
func requestAuthorizationIfNeeded() async -> Bool {
|
||||
let status = AVCaptureDevice.authorizationStatus(for: .video)
|
||||
|
||||
// Determine if the user previously authorized camera access.
|
||||
if status == .authorized {
|
||||
return true
|
||||
}
|
||||
|
||||
var isAuthorized = false
|
||||
// If the system hasn't determined the user's authorization status,
|
||||
// explicitly prompt them for approval.
|
||||
if status == .notDetermined {
|
||||
isAuthorized = await AVCaptureDevice.requestAccess(for: .video)
|
||||
}
|
||||
|
||||
return isAuthorized
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user