@awesome-cordova-library/vibration
v1.0.2
Published
This plugin provides a way to vibrate the device. Its API aligns with the W3C vibration specification at http://www.w3.org/TR/vibration/
Downloads
31
Maintainers
Readme
id: plugin-vibration title: Vibration tags:
- cordova
- capacitor
- ionic
- javascript
- typescript
- plugin
- mobile
- vibration
Vibration
This plugin provides a way to vibrate the device. Its API aligns with the W3C vibration specification at
Installation
Cordova
cordova plugin add cordova-plugin-vibration
npm install @awesome-cordova-library/vibration
Capacitor / Ionic
npm install cordova-plugin-vibration
npm install @awesome-cordova-library/vibration
npx cap sync
Vanilla
Declaration
class Vibration {
static vibrate(time: number | number[]): void;
}
Usages
import Vibration from "@awesome-cordova-library/vibration";
// Vibrate for 3 seconds
Vibration.vibrate(3000);
// Vibrate for 3 seconds
Vibration.vibrate([3000]);
React
Declaration
const useVibration: () => (time: number | number[]) => void;
Usages
import { useEffect } from "react";
import useVibration from "@awesome-cordova-library/vibration/lib/react";
function App() {
const vibrate = useVibration();
useEffect(() => {
// Vibrate for 1 second
// Wait for 1 second
// Vibrate for 3 seconds
// Wait for 1 second
// Vibrate for 5 seconds
vibrate([1000, 1000, 3000, 1000, 5000]);
}, []);
return <div />;
}
Quirks
Mulitple vibration not supported on iOS