Haptics

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.

Implementation Guide

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

Triger Haptic Vibration Event

↔️GoNative JavaScript Bridge

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

gonative.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 gonative_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 gonative_device_shake(){ 
  document.querySelector('.sideNavigation').style.visibility = "visible"; 
};