Skip to main content

Vibration

EOL Notice

Vibration will reach its end-of-life on July 1, 2024, and will no longer receive updates or support. Please see Support Policy for additional information.

The Vibration plugin provides the ability to vibrate the device for a given amount of time.

Installation

If you have not already setup Ionic Enterprise in your app, follow the one-time setup steps.

Next, install the plugin:

npm install @ionic-enterprise/vibration
npx cap sync

Index

Classes


Classes

Vibration

usage:

import { Vibration } from '@ionic-enterprise/vibration/ngx';

constructor(private vibration: Vibration) { }

...

// Vibrate the device for a second
// Duration is ignored on iOS.
this.vibration.vibrate(1000);

// Vibrate 2 seconds
// Pause for 1 second
// Vibrate for 2 seconds
// Patterns work on Android only
this.vibration.vibrate([2000,1000,2000]);

// Stop any current vibrations immediately
// Works on Android only
this.vibration.vibrate(0);

vibrate

vibrate(time: number | number[]): void

Vibrates the device for given amount of time.

Parameters:

NameTypeDescription
timenumber | number[]Milliseconds to vibrate the device. If passed an array of numbers, it will define a vibration pattern. Pass 0 to stop any vibration immediately.

Returns: void