I am trying to use UIImpactFeedbackGenerator in a AVCaptureSession. I have
AVAudioSession.sharedInstance().setAllowHapticsAndSystemSoundsDuringRecording(true)
to allow haptic feedback while in a session (iOS 13 only).
However, the feedback is always delayed by a half-second or so.
Here is the code that triggers the event
@IBAction func doubleTapGesture(_ sender: UITapGestureRecognizer) {
if #available(iOS 13.0, *) {
DispatchQueue.main.async {
self.UIImpactHapticFeedback!.impactOccurred()
}
}
self.switchCamera
}
I set up the UIImpactHapticFeedback in my viewDidLoad that also prepares the instance.
I believe it has to do with the switching camera action because the haptic feedback will not happen until after the switching camera action is done.
Can someone help me get the haptic feedback to be instant?