Panduan Memulai
Salin prompt setup yang 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-updater`
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/updater/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.
Instalasi
Bagian berjudul “Instalasi”Anda bisa menggunakan AI-Assisted Setup kami untuk menginstal plugin ini. Tambahkan skill Capgo ke tool AI Anda dengan command berikut:
npx 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-updater` plugin in my project.Jika Anda lebih memilih Manual Setup, instal plugin dengan menjalankan perintah berikut dan ikuti petunjuk khusus platform di bawah ini:
bun add @capgo/capacitor-updaterbunx cap syncyarn add @capgo/capacitor-updaterbunx cap syncpnpm add @capgo/capacitor-updaterbunx cap syncbun add @capgo/capacitor-updaterbunx cap syncMulai Cepat
Bagian berjudul “Quick Start”Bagi kebanyakan pengguna, kami menyarankan untuk mengikuti panduan Quickstart utama yang mencakup instalasi plugin dan integrasi cloud Capgo.
Panduan memulai ini berfokus pada detail teknis plugin bagi pengguna tingkat lanjut yang ingin memahami mekanisme dasar atau menerapkan self-hosted updates.
Ikhtisar
Bagian berjudul “Ringkasan”Plugin Capacitor Updater memungkinkan update over-the-air (OTA) untuk aplikasi Capacitor Anda. Ini memungkinkan Anda mengirim update ke aplikasi tanpa melalui proses review app store.
Cara Kerjanya
Bagian berjudul “Cara Kerja”- Unduhan bundle: Plugin mengunduh update bundles (file ZIP yang berisi web assets Anda)
- Ekstraksi: Bundles diekstrak ke penyimpanan perangkat
- Hot Reload: Aplikasi beralih ke bundle baru tanpa perlu restart
- Fallback: Jika update gagal, aplikasi akan kembali ke versi sebelumnya yang stabil
Mode Penggunaan
Bagian berjudul “Usage Modes”1. Mode Auto-Update (Direkomendasikan)
Bagian berjudul “1. Auto-Update Mode (Recommended)”Cara termudah menggunakan plugin dengan manajemen update otomatis:
import { CapacitorUpdater } from '@capgo/capacitor-updater';
// Plugin handles everything automatically// Configure in capacitor.config.tsTambahkan ke capacitor.config.ts:
{ plugins: { CapacitorUpdater: { autoUpdate: 'atBackground', updateUrl: 'https://your-update-server.com/api/updates' } }}2. Mode Manual
Bagian berjudul “2. Manual Mode”Untuk kontrol lebih lanjut atas proses update:
import { CapacitorUpdater } from '@capgo/capacitor-updater';
// Download an updateconst bundle = await CapacitorUpdater.download({ url: 'https://your-server.com/updates/v1.0.1.zip', version: '1.0.1'});
// Set the bundle (will be used on next app start)await CapacitorUpdater.set({ id: bundle.id});
// Or reload immediatelyawait CapacitorUpdater.reload();Konfigurasi Platform
Bagian berjudul “Konfigurasi Platform”Tidak perlu konfigurasi tambahan. Plugin langsung bisa digunakan.
Android
Bagian berjudul “Android”Tidak perlu konfigurasi tambahan. Plugin langsung bisa digunakan.
Penggunaan Dasar API
Bagian berjudul “Penggunaan Dasar API”Download Update
Bagian berjudul “Download Update”import { CapacitorUpdater } from '@capgo/capacitor-updater';
const bundle = await CapacitorUpdater.download({ url: 'https://example.com/update.zip', version: '1.0.1'});
console.log('Downloaded bundle:', bundle.id);Jadikan Bundle Aktif
Bagian berjudul “Jadikan Bundle Aktif”// Set bundle to be used on next app startawait CapacitorUpdater.set({ id: bundle.id});Reload dengan Bundle Baru
Bagian berjudul “Reload dengan Bundle Baru”// Reload app immediately with new bundleawait CapacitorUpdater.reload();Daftar Bundle
Bagian berjudul “Daftar Bundle”const { bundles } = await CapacitorUpdater.list();console.log('Available bundles:', bundles);Hapus Bundle
Bagian berjudul “Delete a Bundle”await CapacitorUpdater.delete({ id: 'bundle-id'});Ambil Bundle Saat Ini
Bagian berjudul “Get Current Bundle”const { bundle } = await CapacitorUpdater.current();console.log('Current bundle:', bundle.version);Event Listeners
Bagian berjudul “Event Listeners”Pantau event update:
import { CapacitorUpdater } from '@capgo/capacitor-updater';
// Listen for download progressCapacitorUpdater.addListener('download', (info) => { console.log('Download progress:', info.percent);});
// Listen for download completionCapacitorUpdater.addListener('downloadComplete', (bundle) => { console.log('Download complete:', bundle.version);});
// Listen for update failuresCapacitorUpdater.addListener('updateFailed', (error) => { console.error('Update failed:', error);});
// Listen for successful updatesCapacitorUpdater.addListener('updateAvailable', (info) => { console.log('Update available:', info.version);});Opsi Konfigurasi
Bagian berjudul “Configuration Options”Konfigurasikan plugin di capacitor.config.ts:
{ plugins: { CapacitorUpdater: { // Auto-update settings autoUpdate: 'atBackground', updateUrl: 'https://api.example.com/updates',
// Update behavior resetWhenUpdate: true,
// Version settings version: '1.0.0',
// Security allowModifyUrl: false,
// Stats collection statsUrl: 'https://api.example.com/stats',
// Channel (for Capgo cloud) defaultChannel: 'production' } }}Pola Integrasi
Bagian berjudul “Pola Integrasi”Dengan Capgo Cloud
Bagian berjudul “Dengan Capgo Cloud”Cara termudah untuk memulai:
// Install the Capgo CLIbun add -g @capgo/cli
// Login to Capgonpx @capgo/cli login
// Upload your first bundlenpx @capgo/cli bundle upload
// The plugin auto-updates from Capgo cloudLihat panduan Quickstart utama detailnya.
Update Self-Hosted
Bagian berjudul “Update Self-Hosted”Host server update Anda sendiri:
// Configure your update endpoint{ plugins: { CapacitorUpdater: { autoUpdate: 'atBackground', updateUrl: 'https://your-server.com/api/check-update' } }}Server Anda harus mengembalikan:
{ "version": "1.0.1", "url": "https://your-server.com/updates/1.0.1.zip"}Lihat Mode Self-Hosted untuk detail lengkapnya.
Alur Update Manual
Bagian berjudul “Alur Update Manual”Kontrol penuh atas update:
import { CapacitorUpdater } from '@capgo/capacitor-updater';
async function checkAndUpdate() { // Check for updates from your server const response = await fetch('https://api.example.com/check-update'); const { version, url } = await response.json();
// Download the update const bundle = await CapacitorUpdater.download({ url, version });
// Notify bundle is ready await CapacitorUpdater.notifyAppReady();
// Set as next version await CapacitorUpdater.set({ id: bundle.id });
// Reload when ready await CapacitorUpdater.reload();}Praktik Terbaik
Bagian berjudul “Praktik Terbaik”- Selalu panggil
notifyAppReady()saat aplikasi berhasil dimuat - Uji update secara menyeluruh sebelum push ke production
- Terapkan error handling yang tepat untuk kegagalan jaringan
- Gunakan nomor versi secara konsisten
- Jaga ukuran bundle tetap kecil agar download lebih cepat
- Pantau tingkat keberhasilan update
Langkah Berikutnya
Bagian berjudul “Langkah Selanjutnya”- Referensi Plugin API - Dokumentasi lengkap API
- Pengaturan Plugin - Semua opsi konfigurasi
- Event - Event update yang tersedia
- Mode Self-Hosted - Jalankan server update sendiri
- Pengembangan Lokal - Test update secara lokal
- Debugging - Panduan troubleshooting
Dukungan
Bagian berjudul “Support”- Masalah Diketahui - Masalah umum dan solusinya
- Diskusi GitHub - Dukungan komunitas
- Discord - Chat real-time
Lanjutkan dari Getting Started
Bagian berjudul “Lanjutkan dari Getting Started”Jika Anda menggunakan Panduan Memulai untuk merencanakan pekerjaan plugin native, hubungkan dengan Menggunakan @capgo/capacitor-updater untuk fitur native di bagian Menggunakan @capgo/capacitor-updater, Direktori Plugin Capgo untuk alur kerja produk di Direktori Plugin Capgo, Plugin Capacitor oleh Capgo untuk detail implementasi pada Capacitor Plugins oleh Capgo Menambahkan atau Memperbarui Plugin untuk detail implementasi di Menambahkan atau Memperbarui Plugin, dan Alternatif Plugin Ionic Enterprise untuk alur kerja produk dalam Alternatif Plugin Ionic Enterprise.