Panduan Memulai
Copy prompt setup berisi langkah install dan panduan markdown lengkap untuk plugin ini.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-volume-buttons`
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/volume-buttons/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.
Anda bisa menggunakan AI-Assisted Setup untuk menginstal plugin ini. Tambahkan skill Capgo ke tool AI Anda menggunakan perintah berikut:
bunx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsLalu gunakan prompt berikut:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-volume-buttons` plugin in my project.Jika Anda lebih suka Manual Setup, instal plugin dengan menjalankan perintah berikut dan ikuti instruksi khusus platform di bawah ini:
bun add @capgo/capacitor-volume-buttonsbunx cap syncimport { VolumeButtons } from '@capgo/capacitor-volume-buttons';Mulai cepat
Bagian berjudul “Mulai cepat”import { VolumeButtons } from '@capgo/capacitor-volume-buttons';
const listener = await VolumeButtons.addListener( 'volumeButtonPressed', (event) => { console.log(`Volume ${event.direction} button pressed`); });
// Remove listener when doneawait listener.remove();Contoh: removeAllListeners
Bagian berjudul “Contoh: removeAllListeners”import { VolumeButtons } from '@capgo/capacitor-volume-buttons';
await VolumeButtons.removeAllListeners();Contoh: getPluginVersion
Bagian berjudul “Contoh: getPluginVersion”import { VolumeButtons } from '@capgo/capacitor-volume-buttons';
const { version } = await VolumeButtons.getPluginVersion();console.log('Plugin version:', version);Masalah umum
Bagian berjudul “Kesalahan umum”- Listeners: hapus handle saat screen unmount.
- Sinkronisasi native: jalankan
bunx cap syncsetelah upgrade plugin. - Sumber kebenaran: percaya
src/definitions.tspada repo GitHub.
Ikhtisar API
Bagian berjudul “Ikhtisar API”addListener
Bagian berjudul “addListener”Pantau penekanan pada tombol volume hardware.
import { VolumeButtons } from '@capgo/capacitor-volume-buttons';
const listener = await VolumeButtons.addListener( 'volumeButtonPressed', (event) => { console.log(`Volume ${event.direction} button pressed`); });
// Remove listener when doneawait listener.remove();removeAllListeners
Bagian berjudul “removeAllListeners”Menghapus semua listener untuk plugin ini.
import { VolumeButtons } from '@capgo/capacitor-volume-buttons';
await VolumeButtons.removeAllListeners();getPluginVersion
Bagian berjudul “getPluginVersion”Dapatkan versi plugin native Capacitor.
import { VolumeButtons } from '@capgo/capacitor-volume-buttons';
const { version } = await VolumeButtons.getPluginVersion();console.log('Plugin version:', version);Referensi Tipe
Bagian berjudul “Type Reference”VolumeButtonListener
Bagian berjudul “VolumeButtonListener”Fungsi listener untuk event tombol volume.
export type VolumeButtonListener = (event: VolumeButtonPressed) => void;VolumeButtonPressed
Bagian berjudul “VolumeButtonPressed”Data event saat tombol volume ditekan.
export interface VolumeButtonPressed { /** Direction of the button press */ direction: VolumeButtonDirection;}VolumeButtonDirection
Bagian berjudul “VolumeButtonDirection”Arah penekanan tombol volume.
export type VolumeButtonDirection = 'up' | 'down';Sumber Kebenaran
Bagian berjudul “Sumber Kebenaran”Halaman ini dibuat dari plugin src/definitions.ts. Jalankan ulang sync saat API publik berubah di upstream.
Lanjutkan dari Getting Started
Bagian berjudul “Lanjutkan dari Getting Started”Jika Anda menggunakan Panduan Memulai untuk merencanakan operasi dashboard dan API, hubungkan dengan Menggunakan @capgo/capacitor-volume-buttons untuk kapabilitas native di Menggunakan @capgo/capacitor-volume-buttons, Ikhtisar API untuk detail implementasi di Ringkasan API, Pendahuluan untuk detail implementasi di Pendahuluan, Kunci API untuk detail implementasi di API Keys, dan Perangkat untuk detail implementasi di Perangkat.