refactor: replace haptic feedback dependencies with native implementation#3554
Open
refactor: replace haptic feedback dependencies with native implementation#3554
Conversation
β¦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).
Contributor
SDK Size
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
π― Goal
Remove the third-party
react-native-haptic-feedbackandexpo-hapticsdependencies 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 asStreamVideoThumbnailGenerator):StreamHapticFeedback.swiftβ usesUIImpactFeedbackGenerator,UINotificationFeedbackGenerator, andUISelectionFeedbackGeneratorto provide all haptic types (impactLight,impactMedium,impactHeavy,notificationSuccess,notificationWarning,notificationError,selection).StreamHapticFeedbackModule.mβ exposes the Swift implementation to React Native viaRCT_EXPORT_MODULE. Dispatches to main thread sinceUIFeedbackGeneratorrequires it. Works on both old and new architecture.StreamHapticFeedback.ktβ usesView.performHapticFeedback()withHapticFeedbackConstants, with API 30+ aware fallbacks forCONFIRM/REJECTconstants.StreamChatReactNativePackageandStreamChatExpoPackage.triggerHaptic.tsfiles (native-package and expo-package) now callNativeModules.StreamHapticFeedbackinstead of the third-party libraries.The
registerNativeHandlerspattern is preserved β users can still override or disable haptic feedback viaregisterNativeHandlers({ triggerHaptic: () => {} }).No changes to the core package (
package/src/) β all component call sites remain unchanged since they access haptics throughNativeHandlers.triggerHaptic().π¨ UI Changes
No visual changes. Haptic feedback behavior is functionally equivalent to the previous implementation.
π§ͺ Testing
yarn buildpasses cleanlyyarn lintpasses with 0 warningsyarn test:unitβ all haptic-related tests pass (MessageReactionPicker: 6/6). Only pre-existing failures remain (SQLite Node.js version mismatch, Gallery timeout)impactMedium)impactLight)impactHeavy,notificationSuccess,notificationError)impactMedium)impactLight)βοΈ Checklist
developbranch