Login to follow
VibratePlugin

VibratePlugin (ODC)

Stable version 0.1.1 (Compatible with ODC)
Uploaded on 1 May by Community Labs
VibratePlugin

VibratePlugin (ODC)

Documentation
0.1.1

Vibration Actions Documentation

This section describes the actions implemented in the component for interacting with the device's vibration feature using the Cordova vibration plugin.

1. CheckPlugin

Description:

This action checks if the Cordova vibration plugin is successfully installed and accessible within the application. It's useful for verifying the plugin's presence before attempting to use its functionalities.

Purpose:

  • To ensure the vibration features are available on the device.
  • Can be used for conditional logic to handle scenarios where the plugin might be missing.

Usage:

This action likely returns a boolean value (e.g., true if the plugin is available, false otherwise) or triggers an event indicating the plugin's status.


2. IsCordovaDefined

Description:

This action checks if the core Cordova object (window.cordova) is defined. The Cordova object is the entry point for accessing all Cordova APIs, including plugins. This check is a fundamental prerequisite for using any Cordova plugin.

Purpose:

  • To ensure that the Cordova environment is initialized before attempting to use any Cordova functionalities.
  • Helps prevent errors that occur when trying to access Cordova APIs before the deviceready event.

Usage:

This action likely returns a boolean value (true if window.cordova is defined, false otherwise).


3. StopVibration

Description:

This action attempts to immediately stop any currently ongoing vibration.

Purpose:

  • To provide a way for the user or the application to halt a vibration in progress.

Platform Considerations:

  • iOS: As noted in the general limitations of the cordova-plugin-vibration, this action might not have any effect on iOS. Once a vibration starts, it will run for its pre-set duration.

Usage:

This action likely calls navigator.vibrate(0) or navigator.vibrate([]) internally.


4. Vibrate

Description:

This action triggers a simple device vibration for a specified duration.

Parameters:

  • time (Number): The duration of the vibration in milliseconds.

Purpose:

  • To provide basic haptic feedback to the user.

Platform Considerations:

  • iOS: The time parameter is ignored. The device will vibrate for a short, default duration.
  • Windows Phone: The time parameter has a maximum value of 5000ms.

Usage:

This action likely calls navigator.vibrate(time).


5. VibrateUsingPattern

Description:

This action triggers a device vibration with a custom pattern. The pattern is defined as an array (alternating) of on/off durations in milliseconds.

Parameters:

  • pattern (Array): An array of numbers representing the vibration and pause intervals in milliseconds. For example, [500, 200, 500] would vibrate for 500ms, pause for 200ms, and then vibrate for another 500ms.

Purpose:

  • To provide more complex and nuanced haptic feedback to the user.

Platform Considerations:

  • iOS: This functionality is not supported. Calling this action on iOS will likely have no effect.

Usage:

This action likely calls navigator.vibrate(pattern).