コンテンツにジャンプ

はじめに

ターミナル画面
bun add @capgo/capacitor-shake
bunx cap sync
import { CapacitorShake } from '@capgo/capacitor-shake';

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

パブリック__CAPGO_KEEP_0__がアップストリームで変更されたときに、再度syncを実行してください src/definitions.ts. Re-run the sync when the public API changes upstream.