Skip to main content

Vibration

Vibrates the device

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

Stuck on a Cordova issue?

Don't waste precious time on plugin issues.

If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic’s experts offer premium advisory services for both community plugins and premier plugins.

Installation#

$ npm install cordova-plugin-vibration
$ npm install @ionic-native/vibration
$ ionic cap sync

Supported Platforms#

  • Android
  • iOS
  • Windows

Usage#

React#

Learn more about using Ionic Native components in React

Angular#

import { Vibration } from '@ionic-native/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);