haptic-feedback-plugin
Mobile icon

Haptic Feedback Plugin

Stable version 1.0.0 (Compatible with OutSystems 11)
Uploaded
 on 05 July 2024
 by 
0.0
 (0 ratings)
haptic-feedback-plugin

Haptic Feedback Plugin

Documentation
1.0.0

How to Use

Playing haptic feedback is as simple as calling the SendHapticFeedback client action. It takes two parameters: the Android type and iOS type, which correspond to their respective system haptic feedback constants (see implementation details below for what the possible values are, and what types of feedback they provide). This client action is non-blocking (e.g. does not wait for an "OK" plugin result and making use of $resolve()) unless there is an error, in which case it uses the standard CommonPlugin Error structure.

Android Implementation

The Android haptic system makes use of the View component pattern and all related constants (see below). Some of these constants require Android API level 34+, so keep that in mind when choosing your MABS version.

  • CLOCK_TICK
    • The user has pressed either an hour or minute tick of a Clock.
  • CONFIRM
    • A haptic effect to signal the confirmation or successful completion of a user interaction.
  • CONTEXT_CLICK
    • The user has performed a context click on an object.
  • DRAG_START
    • The user has started a drag-and-drop gesture.
  • GESTURE_END
    • The user has finished a gesture (e.g. on the soft keyboard).
  • GESTURE_START
    • The user has started a gesture (e.g. on the soft keyboard).
  • GESTURE_THRESHOLD_ACTIVATE
    • The user is executing a swipe/drag-style gesture, such as pull-to-refresh, where the gesture action is "eligible" at a certain threshold of movement, and can be cancelled by moving back past the threshold.
  • GESTURE_THRESHOLD_DEACTIVATE
    • The user is executing a swipe/drag-style gesture, such as pull-to-refresh, where the gesture action is "eligible" at a certain threshold of movement, and can be cancelled by moving back past the threshold.
  • KEYBOARD_PRESS
    • The user has pressed a virtual or software keyboard key.
  • KEYBOARD_RELEASE
    • The user has released a virtual keyboard key.
  • KEYBOARD_TAP
    • The user has pressed a soft keyboard key.
  • LONG_PRESS
    • The user has performed a long press on an object that is resulting in an action being performed
  • REJECT
    • A haptic effect to signal the rejection or failure of a user interaction.
  • SEGMENT_FREQUENT_TICK
    • The user is switching between a series of many potential choices, for example minutes on a clock face, or individual percentages.
  • SEGMENT_TICK
    • The user is switching between a series of potential choices, for example items in a list or discrete points on a slider.
  • TEXT_HANDLE_MOVE
    • The user has performed a selection/insertion handle move on text field.
  • TOGGLE_OFF
    • The user has toggled a switch or button into the off position.
  • TOGGLE_ON
    • The user has toggled a switch or button into the on position.
  • VIRTUAL_KEY
    • The user has pressed on a virtual on-screen key.
  • VIRTUAL_KEY_RELEASE
    • The user has released a virtual key.


iOS Implementation

The iOS haptic systems makes use of the UIFeedbackGenerator subclasses and constants from UIKit, with the exception of UICanvasFeedbackGenerator. Some of the constants require iOS 13+ thus the plugin requirements. Note that these classes are generated on the fly when the feedback is sent in this plugin without making use of prepare() ahead of time, so keep that in mind when considering latency. Also, location-based feedback (passing location coordinates) is not supported, though I might add support in future releases. The constants are:

  • ImpactLight
    • A collision between small, light user interface elements.
  • ImpactMedium
    • A collision between moderately sized user interface elements.
  • ImpactHeavy
    • A collision between large, heavy user interface elements.
  • ImpactSoft
    • A collision between user interface elements that are soft, exhibiting a large amount of compression or elasticity.
  • ImpactRigid
    • A collision between user interface elements that are rigid, exhibiting a small amount of compression or elasticity.
  • Success
    • A notification feedback type that indicates a task has completed successfully.
  • Warning
    • A notification feedback type that indicates a task has produced a warning.
  • Error
    • A notification feedback type that indicates a task has failed.
  • SelectionChanged
    • Use selection feedback to communicate movement through a series of discrete values. For example, you might trigger selection feedback to indicate that a UI element’s values are changing.