Allow Haptic Feedback and System Sounds while recording
This commit is contained in:
23
ios/Extensions/AVAudioSession+trySetAllowHaptics.swift
Normal file
23
ios/Extensions/AVAudioSession+trySetAllowHaptics.swift
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user