Deprecation Notice: As of version 2.0.0,
Haptics::vibrate() has been deprecated in favor of Device::vibrate(). Both methods currently work the same way, but it’s recommended to use the Device facade for future compatibility.Usage
Trigger a haptic vibration:Methods
vibrate()
Deprecated: Use Device::vibrate() instead.
Trigger a short haptic vibration on the device.
Returns: void
Example:
Migration Guide
If you’re usingHaptics::vibrate() in your code, update to use Device::vibrate() instead:
Before:
Examples
Button Press Feedback
Form Submission
Error Notification
Game Interaction
Notification Received
Platform Notes
iOS
- Uses
AudioServicesPlaySystemSoundwithkSystemSoundID_Vibrate - Produces a single, short vibration (approximately 400ms)
- Duration and pattern cannot be customized
- Not available on devices without vibration motor (e.g., iPad)
- Respects user’s haptic feedback settings
- Silent mode does not affect vibration
Android
- Uses
Vibratorsystem service - Default vibration duration: 200-400ms (device dependent)
- Duration and pattern cannot be customized via this API
- Requires
VIBRATEpermission in AndroidManifest.xml - Respects user’s vibration settings
- Works in silent mode
The vibration pattern and duration are controlled by the operating system and may vary between devices. This API triggers a simple, short vibration pulse.
For more advanced haptic feedback patterns, consider using platform-specific implementations through native bridges. This API provides a simple, cross-platform vibration trigger.