メインコンテンツにスキップ

Getting Started

GitHub

CapgoのAI-Assistedセットアップを使用してプラグインをインストールできます。AIツールにCapgoスキルを追加するには、以下のコマンドを実行してください。

ターミナル画面
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-volume-buttons` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

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

ボリュームボタンの押下を検知する

import { VolumeButtons } from '@capgo/capacitor-volume-buttons';
const listener = await VolumeButtons.addListener(
'volumeButtonPressed',
(event) => {
console.log(`Volume ${event.direction} button pressed`);
}
);
// Remove listener when done
await listener.remove();

このプラグインのすべてのリスナーを削除します。

import { VolumeButtons } from '@capgo/capacitor-volume-buttons';
await VolumeButtons.removeAllListeners();

ネイティブ Capacitor プラグインのバージョンを取得します。

import { VolumeButtons } from '@capgo/capacitor-volume-buttons';
const { version } = await VolumeButtons.getPluginVersion();
console.log('Plugin version:', version);

ボリュームボタンのイベントにリスナーを設定します。

export type VolumeButtonListener = (event: VolumeButtonPressed) => void;

ボリュームボタン押下のイベントデータ

export interface VolumeButtonPressed {
/** Direction of the button press */
direction: VolumeButtonDirection;
}

クリップボードにコピー

export type VolumeButtonDirection = 'up' | 'down';

__CAPGO_KEEP_0__がアップストリームで変更された場合に再度同期してください。 src/definitions.ts. Re-run the sync when the public API changes upstream.

あなたが Getting Started を計画ダッシュボードとAPI オペレーションに接続するには Using @capgo/capacitor-volume-buttons capgoのネイティブ機能のためにUsing @capgo/capacitor-volume-buttons API Overview APIの実装詳細のためにAPI Overview Introduction 実装詳細のためにIntroduction API Keys API Keysの実装詳細のために、 Devices __CAPGO_KEEP_0__の実装詳細についての情報は、デバイスのページにあります。