Overview

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/

Implementation Guide

Once the premium module has been added to your app, you may use the following Median JavaScript Bridge commands to access its functionality.

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"; 
};