Skip to content

feat(ios): replace AudioServicesPlaySystemSound with CoreHaptics for Vibration API#55556

Open
hryhoriiK97 wants to merge 4 commits intofacebook:mainfrom
hryhoriiK97:feat/ios-vibration-corehaptics
Open

feat(ios): replace AudioServicesPlaySystemSound with CoreHaptics for Vibration API#55556
hryhoriiK97 wants to merge 4 commits intofacebook:mainfrom
hryhoriiK97:feat/ios-vibration-corehaptics

Conversation

@hryhoriiK97
Copy link

@hryhoriiK97 hryhoriiK97 commented Feb 15, 2026

Summary:

The iOS Vibration API used to rely on AudioServicesPlaySystemSound(kSystemSoundID_Vibrate), which only created a fixed-length vibration - it didn't support custom durations, patterns, or stopping the vibration once started. To work around this, the JavaScript layer used setTimeout to schedule vibrations, but this method wasn't very accurate and couldn't easily be stopped.

This PR replaces the iOS implementation with CoreHaptics (CHHapticEngine), enabling:

  • Custom vibration durationsVibration.vibrate(1000) now produces a 1-second haptic
  • Native pattern playback[pause, vibrate, pause, vibrate, ...] with hardware-level timing
  • Looping with native cancel — repeating patterns loop via CHHapticAdvancedPatternPlayer and stop instantly on cancel()
  • Unified iOS/Android behavior — both platforms now use the same pattern format and native module interface

Changelog:

[IOS] [CHANGED] - Replaced AudioServicesPlaySystemSound with CoreHaptics for Vibration API, enabling custom durations, pattern vibration, and native cancellation on iOS

Test Plan:

Tested on a physical iPhone using RNTester → APIs → Vibration:

  1. Vibrate (default 400ms) — produces a smooth ~400ms continuous haptic
  2. Vibrate for 1 second — produces a noticeably longer 1s haptic
  3. Vibrate pattern [0, 500, 200, 500] — two distinct 500ms pulses with a 200ms gap
  4. Vibrate pattern with repeat — pattern loops continuously until cancel
  5. Cancel — stops repeating pattern instantly
  6. Rapid tapping — no crashes or stacked vibrations

@meta-cla
Copy link

meta-cla bot commented Feb 15, 2026

Hi @hryhoriiK97!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 15, 2026
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants