If I have AVAudioSession configured with .playAndRecord category and a remote IO unit running, what's the besy way to enable haptic feedback on button presses?
Asked
Active
Viewed 50 times
1 Answers
0
You can use UIFeedbackGenerator
to create haptic feedback in your iOS app. You can use one of the below options depends on your requirement:
UIImpactFeedbackGenerator: Use impact feedback generators to indicate that an impact has occurred. For example, you might trigger impact feedback when a user interface object collides with something or snaps into place.
Example:
let impact = UIImpactFeedbackGenerator()
impact.impactOccurred()
UISelectionFeedbackGenerator. Use selection feedback generators to indicate a change in selection.
Example:
let impact = UISelectionFeedbackGenerator()
impact.selectionChanged()
UINotificationFeedbackGenerator. Use notification feedback generators to indicate successes, failures, and warnings.
Example:
let impact = UINotificationFeedbackGenerator()
impact.notificationOccurred(.success)
You can read more info here: https://developer.apple.com/documentation/uikit/uifeedbackgenerator

christijk
- 1,753
- 18
- 26
-
It would not work if you have AVAudioSession with playAndRecord or record categories – Deepak Sharma Jul 23 '20 at 11:28