further refactor to use latest API

pull/1061/head
Ryan ZHAO 4 months ago
parent 403ca8c10c
commit 47f9984d33

@ -323,7 +323,7 @@ extension ConversationVC:
Permissions.requestMicrophonePermissionIfNeeded()
if AVAudioSession.sharedInstance().recordPermission != .granted {
if !Permissions.hasMicrophonePermission {
SNLog("Proceeding without microphone access. Any recorded video will be silent.")
}

@ -169,7 +169,7 @@ final class CallMessageCell: MessageCell {
!Storage.shared[.areCallsEnabled]
) || (
messageInfo.state == .permissionDeniedMicrophone &&
AVAudioSession.sharedInstance().recordPermission != .granted
!Permissions.hasMicrophonePermission
)
)
infoImageViewWidthConstraint.constant = (shouldShowInfoIcon ? CallMessageCell.iconSize : 0)
@ -230,7 +230,7 @@ final class CallMessageCell: MessageCell {
!Storage.shared[.areCallsEnabled]
) || (
messageInfo.state == .permissionDeniedMicrophone &&
AVAudioSession.sharedInstance().recordPermission != .granted
!Permissions.hasMicrophonePermission
)
else { return }

@ -57,9 +57,7 @@ extension Permissions {
presentingViewController: UIViewController? = nil,
onNotGranted: (() -> Void)? = nil
) {
switch AVAudioSession.sharedInstance().recordPermission {
case .granted: break
case .denied:
let handlePermissionDenied: () -> Void = {
guard
Singleton.hasAppContext,
let presentingViewController: UIViewController = (presentingViewController ?? Singleton.appContext.frontmostViewController)
@ -85,13 +83,29 @@ extension Permissions {
)
)
presentingViewController.present(confirmationModal, animated: true, completion: nil)
}
if #available(iOS 17.0, *) {
switch AVAudioApplication.shared.recordPermission {
case .granted: break
case .denied: handlePermissionDenied()
case .undetermined:
onNotGranted?()
AVAudioSession.sharedInstance().requestRecordPermission { _ in }
default: break
}
} else {
switch AVAudioSession.sharedInstance().recordPermission {
case .granted: break
case .denied: handlePermissionDenied()
case .undetermined:
onNotGranted?()
AVAudioSession.sharedInstance().requestRecordPermission { _ in }
default: break
}
}
}
public static func requestLibraryPermissionIfNeeded(

Loading…
Cancel
Save