Haptics

Trigger haptic vibration effects like impact and notification feedback on iOS and Android devices

The Haptics Native Plugin enables you to trigger haptic vibration effects used to provide feedback to end users based on various events and actions within your app. Support is provided for six different haptic effects that have been specifically designed to be comparable across iOS and Android devices.

The plugin also provides support for the "shake" gesture such that a JavaScript callback is invoked when the user shakes their device.

👍

Developer Demo

Display our demo page in your app to test during development https://median.dev/haptics/

Build your haptics-enabled app today

Enter your URL or use our Developer Demo to build an app

Please wait ...
Oops! Something went wrong while loading...

Implementation Guide

Trigger Haptic Vibration Event

↔️Median JavaScript Bridge

Run the following Median JavaScript Bridge command to trigger a haptic effect:

median.haptics.trigger({ style: styleName });

style is a string parameter that can be any of the following options:

iOS and Android

  • impactLight
  • impactMedium
  • impactHeavy
  • notificationSuccess
  • notificationWarning
  • notificationError

Android Only

  • tick
  • click
  • double_click

Respond to Shake Gesture

Add median_device_shake() JavaScript function to all pages that should provide a response to the shake gesture. This function can also be inserted using the Custom JavaScript feature.

For example:

function median_device_shake(){ 
  document.querySelector('.sideNavigation').style.visibility = "visible"; 
};

Haptics Plugin Hands-On

Demo App

💡

Note

To fully experience haptics functionality, please download the sample app provided below. Haptics will not deliver meaningful feedback in a virtual simulator environment.

Median.co Haptics Demo App

Median.co Haptics Demo App

Try the Haptics Plugin

The Haptics Plugin can be trialed - just enable it under Native Plugins in your App Dashboard.

Median App Studio - Haptics Trial

Median App Studio - Haptics Trial

Additional Resources

Want to learn more? Reference the official iOS and Android developer resources below:

📖 Apple Developer - Playing Haptics

📖 Android Developer - Implement haptics on Android