Allow Haptic Feedback and System Sounds while recording

This commit is contained in:
Marc Rousavy
2021-03-26 15:58:08 +01:00
parent 750af31a80
commit 8066f3fb53
3 changed files with 29 additions and 1 deletions

View File

@@ -0,0 +1,23 @@
//
// AVAudioSession+trySetAllowHaptics.swift
// VisionCamera
//
// Created by Marc Rousavy on 26.03.21.
// Copyright © 2021 Facebook. All rights reserved.
//
import Foundation
import AVFoundation
extension AVAudioSession {
/**
Tries to set allowHapticsAndSystemSoundsDuringRecording and ignore errors.
*/
func trySetAllowHaptics(_ allowHaptics: Bool) {
if #available(iOS 13.0, *) {
if !audioSession.allowHapticsAndSystemSoundsDuringRecording {
try? audioSession.setAllowHapticsAndSystemSoundsDuringRecording(true)
}
}
}
}