Getting Started
Salin sebuah prompt pengaturan dengan langkah instalasi 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-auto`
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/auto/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.
-
Instal paket
Jendela terminal npm i @capgo/capacitor-auto -
Sinkronkan proyek native
Jendela terminal npx cap sync -
Atur template root mobil
import { Auto } from '@capgo/capacitor-auto';await Auto.setRootTemplate({title: 'Garage',sections: [{header: 'Doors',items: [{id: 'open-main-door',title: 'Open main door',subtitle: 'Tap to send the action to the phone app',payload: { doorId: 'main' },},],},],}); -
Tangani aksi mobil
await Auto.addListener('carAction', async (event) => {if (event.id === 'open-main-door') {await openGarageDoor(event.payload?.doorId);}}); -
Ikuti status koneksi
const status = await Auto.isAvailable();console.log(status.available, status.connected, status.platform);await Auto.addListener('connectionChanged', (event) => {console.log('Car connected:', event.connected, event.platform);});
Tidak ada data
Judul bagian “Tidak ada data”Tetapkan emptyText ketika template tidak memiliki baris:
await Auto.setRootTemplate({ title: 'Garage', emptyText: 'No actions are available right now.', sections: [],});Kirim pesan jembatan
Judul bagian “Kirim pesan jembatan”Gunakan sendMessage untuk pesan jembatan native yang ditentukan aplikasi:
await Auto.sendMessage({ type: 'status', payload: { online: true },});Pengaturan platform
Judul bagian “Pengaturan platform”- Ikuti langkah-langkah Panduan pengaturan iOS untuk scene CarPlay dan catatan akses. Ikuti langkah-langkah
- Panduan pengaturan Android untuk kategori Android Auto dan catatan manifest. Teruskan dari Getting Started Jika Anda menggunakan
Menggunakan @__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-auto. Teruskan dari Getting Started Jika Anda menggunakan Using @capgo/capacitor-auto untuk kemampuan asli dengan menggunakan @capgo/capacitor-auto, Direktori Plugin Capgo untuk alur kerja produk di Direktori Plugin Capgo, Plugin-Plugin Capacitor oleh Capgo untuk detail implementasi di Plugin-Plugin Capacitor oleh Capgo, Menambahkan atau Mengupdate Plugin untuk detail implementasi di Menambahkan atau Mengupdate Plugin, dan Alternatif Plugin Enterprise Ionic untuk alur kerja produk di Alternatif Plugin Enterprise Ionic.