Skip to content

refactor: replace haptic feedback dependencies with native implementation#3554

Open
oliverlaz wants to merge 1 commit intodevelopfrom
refactor/native-haptic-feedback
Open

refactor: replace haptic feedback dependencies with native implementation#3554
oliverlaz wants to merge 1 commit intodevelopfrom
refactor/native-haptic-feedback

Conversation

@oliverlaz
Copy link
Copy Markdown
Member

🎯 Goal

Remove the third-party react-native-haptic-feedback and expo-haptics dependencies and replace them with a built-in native module. This reduces the number of external dependencies the SDK relies on for haptic feedback.

πŸ›  Implementation details

Follows the existing shared-native/ pattern (same as StreamVideoThumbnailGenerator):

  • iOS (Swift): StreamHapticFeedback.swift β€” uses UIImpactFeedbackGenerator, UINotificationFeedbackGenerator, and UISelectionFeedbackGenerator to provide all haptic types (impactLight, impactMedium, impactHeavy, notificationSuccess, notificationWarning, notificationError, selection).
  • iOS (Obj-C bridge): StreamHapticFeedbackModule.m β€” exposes the Swift implementation to React Native via RCT_EXPORT_MODULE. Dispatches to main thread since UIFeedbackGenerator requires it. Works on both old and new architecture.
  • Android (Kotlin): StreamHapticFeedback.kt β€” uses View.performHapticFeedback() with HapticFeedbackConstants, with API 30+ aware fallbacks for CONFIRM/REJECT constants.
  • Android modules: Registered in both StreamChatReactNativePackage and StreamChatExpoPackage.
  • JS layer: Both triggerHaptic.ts files (native-package and expo-package) now call NativeModules.StreamHapticFeedback instead of the third-party libraries.

The registerNativeHandlers pattern is preserved β€” users can still override or disable haptic feedback via registerNativeHandlers({ triggerHaptic: () => {} }).

No changes to the core package (package/src/) β€” all component call sites remain unchanged since they access haptics through NativeHandlers.triggerHaptic().

🎨 UI Changes

No visual changes. Haptic feedback behavior is functionally equivalent to the previous implementation.

πŸ§ͺ Testing

  • yarn build passes cleanly
  • yarn lint passes with 0 warnings
  • yarn test:unit β€” all haptic-related tests pass (MessageReactionPicker: 6/6). Only pre-existing failures remain (SQLite Node.js version mismatch, Gallery timeout)
  • Manual testing needed on physical devices for haptic feedback in:
    • Message long press (MessageBubble β€” impactMedium)
    • Reaction picker (MessageReactionPicker β€” impactLight)
    • Audio recording start/stop (AudioRecordingButton β€” impactHeavy, notificationSuccess, notificationError)
    • Audio recorder state changes (AudioRecorder β€” impactMedium)
    • Image gallery pinch zoom limits (useImageGalleryGestures β€” impactLight)

β˜‘οΈ Checklist

  • I have signed the Stream CLA (required)
  • PR targets the develop branch
  • Documentation is updated
  • New code is tested in main example apps, including all possible scenarios
    • SampleApp iOS and Android
    • Expo iOS and Android

…native implementation

Remove third-party haptic feedback dependencies (react-native-haptic-feedback,
expo-haptics) and replace them with a built-in native module using the existing
shared-native pattern (Swift + Kotlin).
@oliverlaz oliverlaz requested a review from isekovanic April 16, 2026 10:55
@Stream-SDK-Bot
Copy link
Copy Markdown
Contributor

SDK Size

title develop branch diff status
js_bundle_size 354 KB 354 KB 0 B 🟒

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants