mirror of
https://github.com/stablyai/orca.git
synced 2026-10-13 08:02:52 +00:00
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:
@@ -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(() => {})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user