はじめに
__CAPGO_KEEP_0__
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-shake`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/shake/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
インストール
「インストール」のセクションbun add @capgo/capacitor-shakebunx cap syncインポート
「インポート」のセクションimport { CapacitorShake } from '@capgo/capacitor-shake';APIの概要
「APIの概要」のセクションaddListener
addListenerデバイスの振動イベントをリスンする
デバイスの加速度計を使用して振動パターンを検出するshake検出を使用して、shakeジェスチャーが検出されたときに呼び出されるリスナーを登録します。
import { CapacitorShake } from '@capgo/capacitor-shake';
const listener = await CapacitorShake.addListener('shake', () => { console.log('Shake detected!');});
// To remove the listener:await listener.remove();getPluginVersion
getPluginVersionネイティブCapacitorプラグインのバージョンを取得
ネイティブプラグイン実装の現在のバージョンを返します。
import { CapacitorShake } from '@capgo/capacitor-shake';
const { version } = await CapacitorShake.getPluginVersion();console.log('Plugin version:', version);Source Of Truth
このページはプラグインのパブリック__CAPGO_KEEP_0__がアップストリームで変更されたときに、再度syncを実行してください src/definitions.ts. Re-run the sync when the public API changes upstream.