How to add Haptic feedback using Taptic Engine in iOS Swift?

The Taptic Engine is Apple’s implementation of haptic user interface feedback. This is available from iPhone 7 and above. Let’s understand more about it. Taptic Engine is available from iphone 6s, but iphone 7 has a better version of it.

How to do a basic vibration on iOS devices?

AudioServicesPlaySystemSound(SystemSoundID(kSystemSoundID_Vibrate))

How to generate haptic feedback?

class UIFeedbackGenerator : NSObject

Using Feedback Generators

Feedback generators in action!

UIImpactFeedbackGenerator

let impactFeedbackgenerator = UIImpactFeedbackGenerator(style: .light) 
impactFeedbackgenerator.prepare()
impactFeedbackgenerator.impactOccurred()

UISelectionFeedbackGenerator

let selectionFeedbackGenerator = UISelectionFeedbackGenerator()
selectionFeedbackGenerator.selectionChanged()

UINotificationFeedbackGenerator

let notificationFeedbackGenerator = UINotificationFeedbackGenerator()notificationFeedbackGenerator.prepare()notificationFeedbackGenerator.notificationOccurred(.success)
notificationFeedbackGenerator.notificationOccurred(.warning)
notificationFeedbackGenerator.notificationOccurred(.error)

Keep in mind:

That’s it. !

If you enjoyed reading this post, please share and give some claps so others can find it 👏👏👏👏👏 !!!!

iOS and tvOS developer, dreamer, photographer 🤨

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store