Adding Haptic Feedback to your MAUI app [part 1: MAUI]
This is part of a series of posts dedicated to Haptic Feedback in the .NET multi-platform realm.
The basics
By default, the goal of MAUI is to simplify the developer's work by providing an ultra-simple API. It can't get simpler than this:
// Simple click
HapticFeedback.Default.Perform(HapticFeedbackType.Click);
// Longer click
HapticFeedback.Default.Perform(HapticFeedbackType.LongPress);
Platform considerations
Most of the time, platforms allow the user to disable Haptic Feedback, here are where to find these settings:
🤖 Android
In Android, there is a setting often found under Settings > Sound & vibration > Vibration & haptics.
In addition, you'll need to add the permission for VIBRATE in your AndroidManifest.xml :
<uses-permission android:name="android.permission.VIBRATE" />
🍏 iOS
In iOS you'll need to navigate to Settings > Sounds & Haptics, and enable "System Haptics"
More articles to come, covering the platforms (Android, iOS and Windows) in-depth.
Code sample
Check out my MAUI playground:
Results
You should feel a very faint vibration, even the "LongPress" is not strong. It's normal. These are meant to add a little extra to your User Experience, not to be used as a massage gun ...
We will see on how to unlock this in the next post.
Stay tuned 🙂