fix(mobile): use Android-native haptics API instead of Vibrator

Use performAndroidHapticsAsync on Android which uses HapticFeedbackConstants
instead of the Vibrator API. This fixes haptics not working on Android and
removes the VIBRATE permission requirement.

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Jinwoo-H
2026-04-30 18:03:54 -04:00
co-authored by Orca
parent f19f274314
commit 3bed9df9bc
+9 -3
View File
@@ -1,7 +1,13 @@
import { Platform } from 'react-native'
import * as Haptics from 'expo-haptics'
export function triggerMediumImpact(): void {
void Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium).catch(() => {
// Why: Expo haptics can be unavailable on some Android builds/emulators.
})
if (Platform.OS === 'android') {
// Why: Android's Vibrator API (used by impactAsync) is unreliable for haptic
// feedback. performAndroidHapticsAsync uses the native HapticFeedbackConstants
// API which works without VIBRATE permission and feels more natural.
void Haptics.performAndroidHapticsAsync(Haptics.AndroidHaptics.Long_Press).catch(() => {})
} else {
void Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium).catch(() => {})
}
}