Invoke .NET MAUI Code
Example Project
Setup
Vibration Example
Haptic Feedback Example
Last updated
Last updated
private void button1_Click(object sender, System.EventArgs e)
{
#if ANDROID || IOS
TimeSpan vibrationLength = TimeSpan.FromSeconds(3);
Microsoft.Maui.Devices.Vibration.Default.Vibrate(vibrationLength);
#endif
}private void button1_Click(object sender, System.EventArgs e)
{
#if ANDROID || IOS
Microsoft.Maui.ApplicationModel.MainThread.BeginInvokeOnMainThread(() =>
{
Microsoft.Maui.Devices.HapticFeedback.Default.Perform(Microsoft.Maui.Devices.HapticFeedbackType.LongPress);
});
#endif
}