import SharedKit
SwiftyLaunch Version 1.2+
Add Haptics to your App
Haptics can be very useful to provide feedback to the user, after the user has performed an action. To use Haptics, use the Haptics
class:
Interactive Haptics (Notification)
Best used after a user has performed an action. Is also called when an in-app notification is shown.
func performUserAction() {
// Code
if (success) {
Haptics.notification(type: .success)
} else {
Haptics.notification(type: .error)
}
// Code
}
Three types of notification haptics are available: .success
, .warning
, and .error
.
Impact Haptics (Feedback)
Best used when the user interacts with the app, like tapping a button, to simulate a physical impact.
func buttonTapped() {
Haptics.impact(style: .soft)
}
Three types of impact haptics are available: .light
, .medium
, .heavy
, .soft
, and .rigid
.
⚠️
Don't overuse haptics, as it can be annoying to the user.