Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

Vibration

Improve this doc

Vibrates the device

Repo: https://github.com/apache/cordova-plugin-vibration

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-plugin-vibration
    $ npm install --save @ionic-native/vibration@4
    
  2. Add this plugin to your app's module

Supported platforms

Usage

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

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);

Instance Members

vibrate(time)

Vibrates the device for given amount of time.

Param Type Details
time number|Array.<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.

API

Native

General