Search docs/

Vibration

v3.1.0

Contents

Installation

After following the one-time setup steps, simply install the plugin:

Cordova:ionic cordova plugin add @ionic-enterprise/vibration Capacitor:npm install @ionic-enterprise/vibration npx cap sync

Index

Classes


Classes

Vibration

Vibration:

name: Vibration

description: Vibrates the device

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 and Windows only
this.vibration.vibrate([2000,1000,2000]);

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

vibrate

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

Vibrates the device for given amount of time.

Parameters:

Name Type Description
time number | 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



Other Versions