Using @capgo/capacitor-shake
Capacitor Shake Plugin interface for detecting shake gestures on mobile devices. This plugin allows you to listen for shake events and get plugin version information.
Install
bun add @capgo/capacitor-shake
bunx cap sync
bunx cap sync copies the plugin's native code into your native projects. Run it again after every plugin upgrade.
Import
import { CapacitorShake } from '@capgo/capacitor-shake';
API at a glance
| Method | Description |
|---|---|
addListener |
Listen for shake event on the device. |
getPluginVersion |
Get the native Capacitor plugin version. |
Examples
addListener()
Listen for shake event on the device.
import { CapacitorShake } from '@capgo/capacitor-shake';
const listener = await CapacitorShake.addListener('shake', () => {
console.log('Shake detected!');
});
// To remove the listener:
await listener.remove();
getPluginVersion()
Get the native Capacitor plugin version.
import { CapacitorShake } from '@capgo/capacitor-shake';
const { version } = await CapacitorShake.getPluginVersion();
console.log('Plugin version:', version);
Listen to events
addListener returns a handle. Call handle.remove() when the screen unmounts.
Full reference
Keep going from Using @capgo/capacitor-shake
If you are using Using @capgo/capacitor-shake to plan native plugin work, connect it with @capgo/capacitor-shake for the implementation detail in @capgo/capacitor-shake, Getting Started for the implementation detail in Getting Started, Capgo Plugin Directory for the product workflow in Capgo Plugin Directory, Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, and Adding or Updating Plugins for the implementation detail in Adding or Updating Plugins.