UIImpactFeedbackGenerator Not Working When Audio Device Added to AVCaptureSession
This seems to be an intentional behavior.
You can stop the capture session, play the haptic, then resume the capture session, which appears to be what the camera app is doing, as when you peek the camera feed goes to a blurred static image of the last frame captured. For example:
self.session.stopRunning()// Play hapticUINotificationFeedbackGenerator().notificationOccurred(.warning)// Not completely sure if this delay is needed but you might need to wait until the run loop after the haptic plays to resume capture sessionDispatchQueue.main.asyncAfter(deadline: .now() + 0.1){ self.session.startRunning()}
Audio session (via AVAudioPlayer, AVCaptureMovieFileOutput, etc), then the phone will NOT vibrate.
I am not sure but 99% not working with AVCaptureMovieFileOutput.Please more info:https://developer.apple.com/documentation/audiotoolbox/1405202-audioservicesplayalertsound
Try turn on setAllowHapticsAndSystemSoundsDuringRecording
of AVAudioSession
.